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

Unified Diff: base/threading/sequenced_worker_pool.h

Issue 18650006: base: Make SequencedWorkerPool issue globally unique SequenceTokens. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change CurrentThreadSequenceToken to return a SequenceToken. Created 7 years, 6 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 7e04b071428c838dfcec0faa647f82baf2932045..c41085ba781e01834aa502f7c6a51dab2aa499d7 100644
--- a/base/threading/sequenced_worker_pool.h
+++ b/base/threading/sequenced_worker_pool.h
@@ -126,6 +126,11 @@ class BASE_EXPORT SequencedWorkerPool : public TaskRunner {
return id_ == other.id_;
}
+ // An zero |id_| is a sentinel value internally for unsequenced tasks.
darin (slow to review) 2013/07/05 05:24:19 nit: An -> A, and I think you also meant to put "u
tommycli 2013/07/08 17:42:15 Done.
+ bool IsValid() const {
+ return id_ != 0;
+ }
+
private:
friend class SequencedWorkerPool;
@@ -143,6 +148,11 @@ class BASE_EXPORT SequencedWorkerPool : public TaskRunner {
virtual void OnDestruct() = 0;
};
+ // Gets the SequencedToken of the current thread.
+ // If current thread is not a SequencedWorkerPool worker thread or is running
+ // an unsequenced task, returns an invalid SequenceToken.
+ static SequenceToken CurrentThreadSequenceToken();
darin (slow to review) 2013/07/05 05:24:19 nit: GetSequenceTokenForCurrentThread might be a s
tommycli 2013/07/08 17:42:15 Done.
+
// When constructing a SequencedWorkerPool, there must be a
// MessageLoop on the current thread unless you plan to deliberately
// leak it.
@@ -159,7 +169,7 @@ class BASE_EXPORT SequencedWorkerPool : public TaskRunner {
TestingObserver* observer);
// Returns a unique token that can be used to sequence tasks posted to
- // PostSequencedWorkerTask(). Valid tokens are alwys nonzero.
+ // PostSequencedWorkerTask(). Valid tokens are always nonzero.
SequenceToken GetSequenceToken();
// Returns the sequence token associated with the given name. Calling this

Powered by Google App Engine
This is Rietveld 408576698