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..558712816bf69f375b7e39312389620c9d496d75 100644 |
--- a/base/threading/sequenced_worker_pool.h |
+++ b/base/threading/sequenced_worker_pool.h |
@@ -130,11 +130,19 @@ class BASE_EXPORT SequencedWorkerPool : public TaskRunner { |
return id_ == other.id_; |
} |
+ bool operator==(const SequenceToken& other) const { |
danakj
2015/10/27 20:03:20
Why do we need this?
Bernhard Bauer
2015/10/28 13:36:28
{DCHECK,EXPECT,ASSERT}_EQ use the equality operato
danakj
2015/10/28 18:08:15
I might agree if the operator was only compiled in
Bernhard Bauer
2015/10/28 20:38:13
Ok. Turns out the easiest thing is to just compare
|
+ return Equals(other); |
+ } |
+ |
// Returns false if current thread is executing an unsequenced task. |
bool IsValid() const { |
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,12 +165,16 @@ class BASE_EXPORT SequencedWorkerPool : public TaskRunner { |
// an unsequenced task, returns an invalid SequenceToken. |
static SequenceToken GetSequenceTokenForCurrentThread(); |
danakj
2015/10/27 20:03:20
I think this changes the behaviour of this method
Bernhard Bauer
2015/10/28 13:36:28
Uh, possibly 😃 Basically, the value that is stored
danakj
2015/10/28 18:08:15
Ah, thanks :)
|
+ // 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) |
danakj
2015/10/27 20:03:20
you can let comments wrap at 80
Bernhard Bauer
2015/10/28 13:36:28
Done.
|
- // and a prefix for the thread name to aid in debugging. |
+ // 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); |
@@ -355,6 +367,12 @@ class BASE_EXPORT SequencedWorkerPool : public TaskRunner { |
DISALLOW_COPY_AND_ASSIGN(SequencedWorkerPool); |
}; |
+// Stream operator to allow using a SequenceToken in a DCHECK or testing |
+// assertion. |
+BASE_EXPORT std::ostream& operator<<( |
danakj
2015/10/27 20:03:20
Do we need this?
Bernhard Bauer
2015/10/28 13:36:28
Same as above, this is handy for tests and DCHECKs
danakj
2015/10/28 18:08:15
Similar comment. Can you define this only in the t
|
+ std::ostream& out, |
+ const SequencedWorkerPool::SequenceToken& token); |
+ |
} // namespace base |
#endif // BASE_THREADING_SEQUENCED_WORKER_POOL_H_ |