Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: base/threading/worker_pool_posix.cc

Issue 1845753006: Don't create redundant ThreadData for Worker Threads (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Early return in InitializeThreadContext Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/threading/worker_pool_posix.h" 5 #include "base/threading/worker_pool_posix.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 scoped_refptr<base::PosixDynamicThreadPool> pool_; 73 scoped_refptr<base::PosixDynamicThreadPool> pool_;
74 74
75 DISALLOW_COPY_AND_ASSIGN(WorkerThread); 75 DISALLOW_COPY_AND_ASSIGN(WorkerThread);
76 }; 76 };
77 77
78 void WorkerThread::ThreadMain() { 78 void WorkerThread::ThreadMain() {
79 g_worker_pool_running_on_this_thread.Get().Set(true); 79 g_worker_pool_running_on_this_thread.Get().Set(true);
80 const std::string name = base::StringPrintf("%s/%d", name_prefix_.c_str(), 80 const std::string name = base::StringPrintf("%s/%d", name_prefix_.c_str(),
81 PlatformThread::CurrentId()); 81 PlatformThread::CurrentId());
82 // Note |name.c_str()| must remain valid for for the whole life of the thread. 82 // Note |name.c_str()| must remain valid for for the whole life of the thread.
83 PlatformThread::SetName(name); 83 PlatformThread::SetName(name, true);
jar (doing other things) 2016/04/20 04:34:51 It is surprising to me that this is the *only* pla
Zhenyu Shan 2016/05/04 23:33:03 Android shares posix WorkerThread::ThreadMain code
84 84
85 for (;;) { 85 for (;;) {
86 PendingTask pending_task = pool_->WaitForTask(); 86 PendingTask pending_task = pool_->WaitForTask();
87 if (pending_task.task.is_null()) 87 if (pending_task.task.is_null())
88 break; 88 break;
89 TRACE_EVENT2("toplevel", "WorkerThread::ThreadMain::Run", 89 TRACE_EVENT2("toplevel", "WorkerThread::ThreadMain::Run",
90 "src_file", pending_task.posted_from.file_name(), 90 "src_file", pending_task.posted_from.file_name(),
91 "src_func", pending_task.posted_from.function_name()); 91 "src_func", pending_task.posted_from.function_name());
92 92
93 tracked_objects::TaskStopwatch stopwatch; 93 tracked_objects::TaskStopwatch stopwatch;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 return PendingTask(FROM_HERE, base::Closure()); 187 return PendingTask(FROM_HERE, base::Closure());
188 } 188 }
189 } 189 }
190 190
191 PendingTask pending_task = pending_tasks_.front(); 191 PendingTask pending_task = pending_tasks_.front();
192 pending_tasks_.pop(); 192 pending_tasks_.pop();
193 return pending_task; 193 return pending_task;
194 } 194 }
195 195
196 } // namespace base 196 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698