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

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

Issue 8463004: A couple comment updates (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « base/threading/thread.h ('k') | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/stringprintf.h" 12 #include "base/string_number_conversions.h"
13 #include "base/task.h" 13 #include "base/task.h"
14 #include "base/threading/platform_thread.h" 14 #include "base/threading/platform_thread.h"
15 #include "base/threading/worker_pool.h" 15 #include "base/threading/worker_pool.h"
16 #include "base/tracked_objects.h" 16 #include "base/tracked_objects.h"
17 17
18 namespace base { 18 namespace base {
19 19
20 namespace { 20 namespace {
21 21
22 const int kIdleSecondsBeforeExit = 10 * 60; 22 const int kIdleSecondsBeforeExit = 10 * 60;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 const base::Closure& task, bool task_is_slow) { 56 const base::Closure& task, bool task_is_slow) {
57 pool_->PostTask(from_here, task); 57 pool_->PostTask(from_here, task);
58 } 58 }
59 59
60 base::LazyInstance<WorkerPoolImpl> g_lazy_worker_pool(base::LINKER_INITIALIZED); 60 base::LazyInstance<WorkerPoolImpl> g_lazy_worker_pool(base::LINKER_INITIALIZED);
61 61
62 class WorkerThread : public PlatformThread::Delegate { 62 class WorkerThread : public PlatformThread::Delegate {
63 public: 63 public:
64 WorkerThread(const std::string& name_prefix, 64 WorkerThread(const std::string& name_prefix,
65 base::PosixDynamicThreadPool* pool) 65 base::PosixDynamicThreadPool* pool)
66 : name_prefix_(name_prefix), 66 : name_(name_prefix),
67 pool_(pool) {} 67 pool_(pool) {}
68 68
69 virtual void ThreadMain(); 69 virtual void ThreadMain();
70 70
71 private: 71 private:
72 const std::string name_prefix_; 72 std::string name_;
73 scoped_refptr<base::PosixDynamicThreadPool> pool_; 73 scoped_refptr<base::PosixDynamicThreadPool> pool_;
74 74
75 DISALLOW_COPY_AND_ASSIGN(WorkerThread); 75 DISALLOW_COPY_AND_ASSIGN(WorkerThread);
76 }; 76 };
77 77
78 void WorkerThread::ThreadMain() { 78 void WorkerThread::ThreadMain() {
79 const std::string name = base::StringPrintf( 79 name_.reserve(name_.size() + 10);
jar (doing other things) 2011/11/04 15:30:32 nit: Reserve is not needed.
joth 2011/11/04 16:41:25 will remove
80 "%s/%d", name_prefix_.c_str(), PlatformThread::CurrentId()); 80 name_.push_back('/');
81 PlatformThread::SetName(name.c_str()); 81 name_.append(IntToString(PlatformThread::CurrentId()));
82 PlatformThread::SetName(name_.c_str());
82 83
83 for (;;) { 84 for (;;) {
84 PosixDynamicThreadPool::PendingTask pending_task = pool_->WaitForTask(); 85 PosixDynamicThreadPool::PendingTask pending_task = pool_->WaitForTask();
85 if (pending_task.task.is_null()) 86 if (pending_task.task.is_null())
86 break; 87 break;
87 UNSHIPPED_TRACE_EVENT2("task", "WorkerThread::ThreadMain::Run", 88 UNSHIPPED_TRACE_EVENT2("task", "WorkerThread::ThreadMain::Run",
88 "src_file", pending_task.posted_from.file_name(), 89 "src_file", pending_task.posted_from.file_name(),
89 "src_func", pending_task.posted_from.function_name()); 90 "src_func", pending_task.posted_from.function_name());
90 91
91 tracked_objects::TrackedTime start_time = 92 tracked_objects::TrackedTime start_time =
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 return PendingTask(FROM_HERE, base::Closure()); 218 return PendingTask(FROM_HERE, base::Closure());
218 } 219 }
219 } 220 }
220 221
221 PendingTask pending_task = pending_tasks_.front(); 222 PendingTask pending_task = pending_tasks_.front();
222 pending_tasks_.pop(); 223 pending_tasks_.pop();
223 return pending_task; 224 return pending_task;
224 } 225 }
225 226
226 } // namespace base 227 } // namespace base
OLDNEW
« no previous file with comments | « base/threading/thread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698