| 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 {
|
| + 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();
|
|
|
| + // 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.
|
| + // 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<<(
|
| + std::ostream& out,
|
| + const SequencedWorkerPool::SequenceToken& token);
|
| +
|
| } // namespace base
|
|
|
| #endif // BASE_THREADING_SEQUENCED_WORKER_POOL_H_
|
|
|