| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 g_worker_pool_running_on_this_thread.Get().Set(true); | 84 g_worker_pool_running_on_this_thread.Get().Set(true); |
| 85 const std::string name = base::StringPrintf( | 85 const std::string name = base::StringPrintf( |
| 86 "%s/%d", name_prefix_.c_str(), PlatformThread::CurrentId()); | 86 "%s/%d", name_prefix_.c_str(), PlatformThread::CurrentId()); |
| 87 // Note |name.c_str()| must remain valid for for the whole life of the thread. | 87 // Note |name.c_str()| must remain valid for for the whole life of the thread. |
| 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("task", "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 TrackedTime start_time = |
| 99 tracked_objects::ThreadData::NowForStartOfRun(pending_task.birth_tally); | 99 tracked_objects::ThreadData::NowForStartOfRun(pending_task.birth_tally); |
| 100 | 100 |
| 101 pending_task.task.Run(); | 101 pending_task.task.Run(); |
| 102 | 102 |
| 103 tracked_objects::ThreadData::TallyRunOnWorkerThreadIfTracking( | 103 tracked_objects::ThreadData::TallyRunOnWorkerThreadIfTracking( |
| 104 pending_task.birth_tally, TrackedTime(pending_task.time_posted), | 104 pending_task.birth_tally, TrackedTime(pending_task.time_posted), |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 return PendingTask(FROM_HERE, base::Closure()); | 193 return PendingTask(FROM_HERE, base::Closure()); |
| 194 } | 194 } |
| 195 } | 195 } |
| 196 | 196 |
| 197 PendingTask pending_task = pending_tasks_.front(); | 197 PendingTask pending_task = pending_tasks_.front(); |
| 198 pending_tasks_.pop(); | 198 pending_tasks_.pop(); |
| 199 return pending_task; | 199 return pending_task; |
| 200 } | 200 } |
| 201 | 201 |
| 202 } // namespace base | 202 } // namespace base |
| OLD | NEW |