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 <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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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); |
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_TASK_EXECUTION("WorkerThread::ThreadMain::Run", pending_task); | 89 TRACE_EVENT2("toplevel", "WorkerThread::ThreadMain::Run", |
| 90 "src_file", pending_task.posted_from.file_name(), |
| 91 "src_func", pending_task.posted_from.function_name()); |
90 | 92 |
91 tracked_objects::TaskStopwatch stopwatch; | 93 tracked_objects::TaskStopwatch stopwatch; |
92 stopwatch.Start(); | 94 stopwatch.Start(); |
93 pending_task.task.Run(); | 95 pending_task.task.Run(); |
94 stopwatch.Stop(); | 96 stopwatch.Stop(); |
95 | 97 |
96 tracked_objects::ThreadData::TallyRunOnWorkerThreadIfTracking( | 98 tracked_objects::ThreadData::TallyRunOnWorkerThreadIfTracking( |
97 pending_task.birth_tally, pending_task.time_posted, stopwatch); | 99 pending_task.birth_tally, pending_task.time_posted, stopwatch); |
98 } | 100 } |
99 | 101 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 return PendingTask(FROM_HERE, base::Closure()); | 187 return PendingTask(FROM_HERE, base::Closure()); |
186 } | 188 } |
187 } | 189 } |
188 | 190 |
189 PendingTask pending_task = pending_tasks_.front(); | 191 PendingTask pending_task = pending_tasks_.front(); |
190 pending_tasks_.pop(); | 192 pending_tasks_.pop(); |
191 return pending_task; | 193 return pending_task; |
192 } | 194 } |
193 | 195 |
194 } // namespace base | 196 } // namespace base |
OLD | NEW |