| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 void WorkerThread::ThreadMain() { | 74 void WorkerThread::ThreadMain() { |
| 75 const std::string name = base::StringPrintf( | 75 const std::string name = base::StringPrintf( |
| 76 "%s/%d", name_prefix_.c_str(), PlatformThread::CurrentId()); | 76 "%s/%d", name_prefix_.c_str(), PlatformThread::CurrentId()); |
| 77 // Note |name.c_str()| must remain valid for for the whole life of the thread. | 77 // Note |name.c_str()| must remain valid for for the whole life of the thread. |
| 78 PlatformThread::SetName(name.c_str()); | 78 PlatformThread::SetName(name.c_str()); |
| 79 | 79 |
| 80 for (;;) { | 80 for (;;) { |
| 81 PendingTask pending_task = pool_->WaitForTask(); | 81 PendingTask pending_task = pool_->WaitForTask(); |
| 82 if (pending_task.task.is_null()) | 82 if (pending_task.task.is_null()) |
| 83 break; | 83 break; |
| 84 UNSHIPPED_TRACE_EVENT2("task", "WorkerThread::ThreadMain::Run", | 84 TRACE_EVENT2("task", "WorkerThread::ThreadMain::Run", |
| 85 "src_file", pending_task.posted_from.file_name(), | 85 "src_file", pending_task.posted_from.file_name(), |
| 86 "src_func", pending_task.posted_from.function_name()); | 86 "src_func", pending_task.posted_from.function_name()); |
| 87 | 87 |
| 88 TrackedTime start_time = | 88 TrackedTime start_time = |
| 89 tracked_objects::ThreadData::NowForStartOfRun(pending_task.birth_tally); | 89 tracked_objects::ThreadData::NowForStartOfRun(pending_task.birth_tally); |
| 90 | 90 |
| 91 pending_task.task.Run(); | 91 pending_task.task.Run(); |
| 92 | 92 |
| 93 tracked_objects::ThreadData::TallyRunOnWorkerThreadIfTracking( | 93 tracked_objects::ThreadData::TallyRunOnWorkerThreadIfTracking( |
| 94 pending_task.birth_tally, TrackedTime(pending_task.time_posted), | 94 pending_task.birth_tally, TrackedTime(pending_task.time_posted), |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 return PendingTask(FROM_HERE, base::Closure()); | 179 return PendingTask(FROM_HERE, base::Closure()); |
| 180 } | 180 } |
| 181 } | 181 } |
| 182 | 182 |
| 183 PendingTask pending_task = pending_tasks_.front(); | 183 PendingTask pending_task = pending_tasks_.front(); |
| 184 pending_tasks_.pop(); | 184 pending_tasks_.pop(); |
| 185 return pending_task; | 185 return pending_task; |
| 186 } | 186 } |
| 187 | 187 |
| 188 } // namespace base | 188 } // namespace base |
| OLD | NEW |