OLD | NEW |
---|---|
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/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 PlatformThread::SetName(name.c_str()); | 88 PlatformThread::SetName(name.c_str()); |
89 | 89 |
90 for (;;) { | 90 for (;;) { |
91 PendingTask pending_task = pool_->WaitForTask(); | 91 PendingTask pending_task = pool_->WaitForTask(); |
92 if (pending_task.task.is_null()) | 92 if (pending_task.task.is_null()) |
93 break; | 93 break; |
94 TRACE_EVENT2("toplevel", "WorkerThread::ThreadMain::Run", | 94 TRACE_EVENT2("toplevel", "WorkerThread::ThreadMain::Run", |
95 "src_file", pending_task.posted_from.file_name(), | 95 "src_file", pending_task.posted_from.file_name(), |
96 "src_func", pending_task.posted_from.function_name()); | 96 "src_func", pending_task.posted_from.function_name()); |
97 | 97 |
98 TrackedTime start_time = | 98 tracked_objects::TaskStopwatch stopwatch; |
99 tracked_objects::ThreadData::NowForStartOfRun(pending_task.birth_tally); | 99 stopwatch.Start(tracked_objects::ThreadData::NowForStartOfRun( |
100 | 100 pending_task.birth_tally)); |
101 pending_task.task.Run(); | 101 pending_task.task.Run(); |
102 stopwatch.Stop(tracked_objects::ThreadData::NowForEndOfRun()); | |
102 | 103 |
103 tracked_objects::ThreadData::TallyRunOnWorkerThreadIfTracking( | 104 tracked_objects::ThreadData::TallyRunOnWorkerThreadIfTracking( |
104 pending_task.birth_tally, TrackedTime(pending_task.time_posted), | 105 pending_task.birth_tally, TrackedTime(pending_task.time_posted), |
jar (doing other things)
2014/09/02 16:52:16
*IF* you pushed the Stop() call into TallyRunOnWor
vadimt
2014/09/02 22:41:37
IF ;-)
| |
105 start_time, tracked_objects::ThreadData::NowForEndOfRun()); | 106 stopwatch); |
106 } | 107 } |
107 | 108 |
108 // The WorkerThread is non-joinable, so it deletes itself. | 109 // The WorkerThread is non-joinable, so it deletes itself. |
109 delete this; | 110 delete this; |
110 } | 111 } |
111 | 112 |
112 } // namespace | 113 } // namespace |
113 | 114 |
114 // static | 115 // static |
115 bool WorkerPool::PostTask(const tracked_objects::Location& from_here, | 116 bool WorkerPool::PostTask(const tracked_objects::Location& from_here, |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
193 return PendingTask(FROM_HERE, base::Closure()); | 194 return PendingTask(FROM_HERE, base::Closure()); |
194 } | 195 } |
195 } | 196 } |
196 | 197 |
197 PendingTask pending_task = pending_tasks_.front(); | 198 PendingTask pending_task = pending_tasks_.front(); |
198 pending_tasks_.pop(); | 199 pending_tasks_.pop(); |
199 return pending_task; | 200 return pending_task; |
200 } | 201 } |
201 | 202 |
202 } // namespace base | 203 } // namespace base |
OLD | NEW |