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

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

Issue 1128733002: Update from https://crrev.com/328418 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « base/threading/worker_pool.h ('k') | base/threading/worker_pool_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 scoped_refptr<base::PosixDynamicThreadPool> pool_; 70 scoped_refptr<base::PosixDynamicThreadPool> pool_;
71 71
72 DISALLOW_COPY_AND_ASSIGN(WorkerThread); 72 DISALLOW_COPY_AND_ASSIGN(WorkerThread);
73 }; 73 };
74 74
75 void WorkerThread::ThreadMain() { 75 void WorkerThread::ThreadMain() {
76 g_worker_pool_running_on_this_thread.Get().Set(true); 76 g_worker_pool_running_on_this_thread.Get().Set(true);
77 const std::string name = base::StringPrintf( 77 const std::string name = base::StringPrintf(
78 "%s/%d", name_prefix_.c_str(), PlatformThread::CurrentId()); 78 "%s/%d", name_prefix_.c_str(), PlatformThread::CurrentId());
79 // Note |name.c_str()| must remain valid for for the whole life of the thread. 79 // Note |name.c_str()| must remain valid for for the whole life of the thread.
80 PlatformThread::SetName(name.c_str()); 80 PlatformThread::SetName(name);
81 81
82 for (;;) { 82 for (;;) {
83 PendingTask pending_task = pool_->WaitForTask(); 83 PendingTask pending_task = pool_->WaitForTask();
84 if (pending_task.task.is_null()) 84 if (pending_task.task.is_null())
85 break; 85 break;
86 TRACE_EVENT2("toplevel", "WorkerThread::ThreadMain::Run", 86 TRACE_EVENT2("toplevel", "WorkerThread::ThreadMain::Run",
87 "src_file", pending_task.posted_from.file_name(), 87 "src_file", pending_task.posted_from.file_name(),
88 "src_func", pending_task.posted_from.function_name()); 88 "src_func", pending_task.posted_from.function_name());
89 89
90 tracked_objects::ThreadData::PrepareForStartOfRun(pending_task.birth_tally);
91 tracked_objects::TaskStopwatch stopwatch; 90 tracked_objects::TaskStopwatch stopwatch;
92 stopwatch.Start(); 91 stopwatch.Start();
93 pending_task.task.Run(); 92 pending_task.task.Run();
94 stopwatch.Stop(); 93 stopwatch.Stop();
95 94
96 tracked_objects::ThreadData::TallyRunOnWorkerThreadIfTracking( 95 tracked_objects::ThreadData::TallyRunOnWorkerThreadIfTracking(
97 pending_task.birth_tally, pending_task.time_posted, stopwatch); 96 pending_task.birth_tally, pending_task.time_posted, stopwatch);
98 } 97 }
99 98
100 // The WorkerThread is non-joinable, so it deletes itself. 99 // The WorkerThread is non-joinable, so it deletes itself.
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 return PendingTask(FROM_HERE, base::Closure()); 184 return PendingTask(FROM_HERE, base::Closure());
186 } 185 }
187 } 186 }
188 187
189 PendingTask pending_task = pending_tasks_.front(); 188 PendingTask pending_task = pending_tasks_.front();
190 pending_tasks_.pop(); 189 pending_tasks_.pop();
191 return pending_task; 190 return pending_task;
192 } 191 }
193 192
194 } // namespace base 193 } // namespace base
OLDNEW
« no previous file with comments | « base/threading/worker_pool.h ('k') | base/threading/worker_pool_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698