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

Unified Diff: base/threading/sequenced_worker_pool.h

Issue 1423773003: Add SequencedTaskRunnerHandle to get a SequencedTaskRunner for the current thread / sequence. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: export SequenceToken Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: base/threading/sequenced_worker_pool.h
diff --git a/base/threading/sequenced_worker_pool.h b/base/threading/sequenced_worker_pool.h
index ee282bc231207ec18b511ab51dfe5eb9fee93306..9369fb7adea535ea262a41ffe3850f133eddcb97 100644
--- a/base/threading/sequenced_worker_pool.h
+++ b/base/threading/sequenced_worker_pool.h
@@ -121,7 +121,7 @@ class BASE_EXPORT SequencedWorkerPool : public TaskRunner {
// Opaque identifier that defines sequencing of tasks posted to the worker
// pool.
- class SequenceToken {
+ class BASE_EXPORT SequenceToken {
public:
SequenceToken() : id_(0) {}
~SequenceToken() {}
@@ -135,6 +135,10 @@ class BASE_EXPORT SequencedWorkerPool : public TaskRunner {
return id_ != 0;
}
+ // Returns a string representation of this token. This method should only be
+ // used for debugging.
+ std::string ToString() const;
+
private:
friend class SequencedWorkerPool;
@@ -157,17 +161,21 @@ class BASE_EXPORT SequencedWorkerPool : public TaskRunner {
// an unsequenced task, returns an invalid SequenceToken.
static SequenceToken GetSequenceTokenForCurrentThread();
+ // Returns the SequencedWorkerPool that owns this thread, or null if the
+ // current thread is not a SequencedWorkerPool worker thread.
+ static scoped_refptr<SequencedWorkerPool> GetWorkerPoolForCurrentThread();
+
// When constructing a SequencedWorkerPool, there must be a
- // MessageLoop on the current thread unless you plan to deliberately
- // leak it.
+ // ThreadTaskRunnerHandle on the current thread unless you plan to
+ // deliberately leak it.
// Pass the maximum number of threads (they will be lazily created as needed)
// and a prefix for the thread name to aid in debugging.
SequencedWorkerPool(size_t max_threads,
const std::string& thread_name_prefix);
- // Like above, but with |observer| for testing. Does not take
- // ownership of |observer|.
+ // Like above, but with |observer| for testing. Does not take ownership of
+ // |observer|.
SequencedWorkerPool(size_t max_threads,
const std::string& thread_name_prefix,
TestingObserver* observer);

Powered by Google App Engine
This is Rietveld 408576698