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

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

Issue 2637843002: Migrate base::TaskRunner from Closure to OnceClosure (Closed)
Patch Set: rebase Created 3 years, 8 months 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
« no previous file with comments | « base/threading/worker_pool.cc ('k') | base/threading/worker_pool_posix.cc » ('j') | 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) 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 // The thread pool used in the POSIX implementation of WorkerPool dynamically 5 // The thread pool used in the POSIX implementation of WorkerPool dynamically
6 // adds threads as necessary to handle all tasks. It keeps old threads around 6 // adds threads as necessary to handle all tasks. It keeps old threads around
7 // for a period of time to allow them to be reused. After this waiting period, 7 // for a period of time to allow them to be reused. After this waiting period,
8 // the threads exit. This thread pool uses non-joinable threads, therefore 8 // the threads exit. This thread pool uses non-joinable threads, therefore
9 // worker threads are not joined during process shutdown. This means that 9 // worker threads are not joined during process shutdown. This means that
10 // potentially long running tasks (such as DNS lookup) do not block process 10 // potentially long running tasks (such as DNS lookup) do not block process
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 : public RefCountedThreadSafe<PosixDynamicThreadPool> { 44 : public RefCountedThreadSafe<PosixDynamicThreadPool> {
45 public: 45 public:
46 class PosixDynamicThreadPoolPeer; 46 class PosixDynamicThreadPoolPeer;
47 47
48 // All worker threads will share the same |name_prefix|. They will exit after 48 // All worker threads will share the same |name_prefix|. They will exit after
49 // |idle_seconds_before_exit|. 49 // |idle_seconds_before_exit|.
50 PosixDynamicThreadPool(const std::string& name_prefix, 50 PosixDynamicThreadPool(const std::string& name_prefix,
51 int idle_seconds_before_exit); 51 int idle_seconds_before_exit);
52 52
53 // Adds |task| to the thread pool. 53 // Adds |task| to the thread pool.
54 void PostTask(const tracked_objects::Location& from_here, Closure task); 54 void PostTask(const tracked_objects::Location& from_here, OnceClosure task);
55 55
56 // Worker thread method to wait for up to |idle_seconds_before_exit| for more 56 // Worker thread method to wait for up to |idle_seconds_before_exit| for more
57 // work from the thread pool. Returns NULL if no work is available. 57 // work from the thread pool. Returns NULL if no work is available.
58 PendingTask WaitForTask(); 58 PendingTask WaitForTask();
59 59
60 private: 60 private:
61 friend class RefCountedThreadSafe<PosixDynamicThreadPool>; 61 friend class RefCountedThreadSafe<PosixDynamicThreadPool>;
62 friend class PosixDynamicThreadPoolPeer; 62 friend class PosixDynamicThreadPoolPeer;
63 63
64 ~PosixDynamicThreadPool(); 64 ~PosixDynamicThreadPool();
(...skipping 16 matching lines...) Expand all
81 // Only used for tests to ensure correct thread ordering. It will always be 81 // Only used for tests to ensure correct thread ordering. It will always be
82 // NULL in non-test code. 82 // NULL in non-test code.
83 std::unique_ptr<ConditionVariable> num_idle_threads_cv_; 83 std::unique_ptr<ConditionVariable> num_idle_threads_cv_;
84 84
85 DISALLOW_COPY_AND_ASSIGN(PosixDynamicThreadPool); 85 DISALLOW_COPY_AND_ASSIGN(PosixDynamicThreadPool);
86 }; 86 };
87 87
88 } // namespace base 88 } // namespace base
89 89
90 #endif // BASE_THREADING_WORKER_POOL_POSIX_H_ 90 #endif // BASE_THREADING_WORKER_POOL_POSIX_H_
OLDNEW
« no previous file with comments | « base/threading/worker_pool.cc ('k') | base/threading/worker_pool_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698