summaryrefslogtreecommitdiffstats
path: root/base/threading/sequenced_worker_pool.cc
diff options
context:
space:
mode:
Diffstat (limited to 'base/threading/sequenced_worker_pool.cc')
-rw-r--r--base/threading/sequenced_worker_pool.cc74
1 files changed, 70 insertions, 4 deletions
diff --git a/base/threading/sequenced_worker_pool.cc b/base/threading/sequenced_worker_pool.cc
index 3bc26b4..59c4187 100644
--- a/base/threading/sequenced_worker_pool.cc
+++ b/base/threading/sequenced_worker_pool.cc
@@ -62,6 +62,9 @@ class SequencedWorkerPoolTaskRunner : public TaskRunner {
// TaskRunner implementation
virtual bool PostDelayedTask(const tracked_objects::Location& from_here,
const Closure& task,
+ int64 delay_ms) OVERRIDE;
+ virtual bool PostDelayedTask(const tracked_objects::Location& from_here,
+ const Closure& task,
TimeDelta delay) OVERRIDE;
virtual bool RunsTasksOnCurrentThread() const OVERRIDE;
@@ -73,6 +76,10 @@ class SequencedWorkerPoolTaskRunner : public TaskRunner {
bool PostDelayedTaskAssertZeroDelay(
const tracked_objects::Location& from_here,
const Closure& task,
+ int64 delay_ms);
+ bool PostDelayedTaskAssertZeroDelay(
+ const tracked_objects::Location& from_here,
+ const Closure& task,
TimeDelta delay);
const scoped_refptr<SequencedWorkerPool> pool_;
@@ -95,6 +102,13 @@ SequencedWorkerPoolTaskRunner::~SequencedWorkerPoolTaskRunner() {
bool SequencedWorkerPoolTaskRunner::PostDelayedTask(
const tracked_objects::Location& from_here,
const Closure& task,
+ int64 delay_ms) {
+ return PostDelayedTaskAssertZeroDelay(from_here, task, delay_ms);
+}
+
+bool SequencedWorkerPoolTaskRunner::PostDelayedTask(
+ const tracked_objects::Location& from_here,
+ const Closure& task,
TimeDelta delay) {
return PostDelayedTaskAssertZeroDelay(from_here, task, delay);
}
@@ -106,15 +120,24 @@ bool SequencedWorkerPoolTaskRunner::RunsTasksOnCurrentThread() const {
bool SequencedWorkerPoolTaskRunner::PostDelayedTaskAssertZeroDelay(
const tracked_objects::Location& from_here,
const Closure& task,
- TimeDelta delay) {
+ int64 delay_ms) {
// TODO(francoisk777@gmail.com): Change the following two statements once
// SequencedWorkerPool supports non-zero delays.
- DCHECK_EQ(delay.InMillisecondsRoundedUp(), 0)
+ DCHECK_EQ(delay_ms, 0)
<< "SequencedWorkerPoolTaskRunner does not yet support non-zero delays";
return pool_->PostWorkerTaskWithShutdownBehavior(
from_here, task, shutdown_behavior_);
}
+bool SequencedWorkerPoolTaskRunner::PostDelayedTaskAssertZeroDelay(
+ const tracked_objects::Location& from_here,
+ const Closure& task,
+ TimeDelta delay) {
+ return PostDelayedTaskAssertZeroDelay(from_here,
+ task,
+ delay.InMillisecondsRoundedUp());
+}
+
// SequencedWorkerPoolSequencedTaskRunner ------------------------------------
// A SequencedTaskRunner which posts tasks to a SequencedWorkerPool with a
// fixed sequence token.
@@ -130,6 +153,9 @@ class SequencedWorkerPoolSequencedTaskRunner : public SequencedTaskRunner {
// TaskRunner implementation
virtual bool PostDelayedTask(const tracked_objects::Location& from_here,
const Closure& task,
+ int64 delay_ms) OVERRIDE;
+ virtual bool PostDelayedTask(const tracked_objects::Location& from_here,
+ const Closure& task,
TimeDelta delay) OVERRIDE;
virtual bool RunsTasksOnCurrentThread() const OVERRIDE;
@@ -137,6 +163,10 @@ class SequencedWorkerPoolSequencedTaskRunner : public SequencedTaskRunner {
virtual bool PostNonNestableDelayedTask(
const tracked_objects::Location& from_here,
const Closure& task,
+ int64 delay_ms) OVERRIDE;
+ virtual bool PostNonNestableDelayedTask(
+ const tracked_objects::Location& from_here,
+ const Closure& task,
TimeDelta delay) OVERRIDE;
private:
@@ -147,6 +177,10 @@ class SequencedWorkerPoolSequencedTaskRunner : public SequencedTaskRunner {
bool PostDelayedTaskAssertZeroDelay(
const tracked_objects::Location& from_here,
const Closure& task,
+ int64 delay_ms);
+ bool PostDelayedTaskAssertZeroDelay(
+ const tracked_objects::Location& from_here,
+ const Closure& task,
TimeDelta delay);
const scoped_refptr<SequencedWorkerPool> pool_;
@@ -174,6 +208,13 @@ SequencedWorkerPoolSequencedTaskRunner::
bool SequencedWorkerPoolSequencedTaskRunner::PostDelayedTask(
const tracked_objects::Location& from_here,
const Closure& task,
+ int64 delay_ms) {
+ return PostDelayedTaskAssertZeroDelay(from_here, task, delay_ms);
+}
+
+bool SequencedWorkerPoolSequencedTaskRunner::PostDelayedTask(
+ const tracked_objects::Location& from_here,
+ const Closure& task,
TimeDelta delay) {
return PostDelayedTaskAssertZeroDelay(from_here, task, delay);
}
@@ -185,6 +226,13 @@ bool SequencedWorkerPoolSequencedTaskRunner::RunsTasksOnCurrentThread() const {
bool SequencedWorkerPoolSequencedTaskRunner::PostNonNestableDelayedTask(
const tracked_objects::Location& from_here,
const Closure& task,
+ int64 delay_ms) {
+ return PostDelayedTaskAssertZeroDelay(from_here, task, delay_ms);
+}
+
+bool SequencedWorkerPoolSequencedTaskRunner::PostNonNestableDelayedTask(
+ const tracked_objects::Location& from_here,
+ const Closure& task,
TimeDelta delay) {
return PostDelayedTaskAssertZeroDelay(from_here, task, delay);
}
@@ -192,16 +240,25 @@ bool SequencedWorkerPoolSequencedTaskRunner::PostNonNestableDelayedTask(
bool SequencedWorkerPoolSequencedTaskRunner::PostDelayedTaskAssertZeroDelay(
const tracked_objects::Location& from_here,
const Closure& task,
- TimeDelta delay) {
+ int64 delay_ms) {
// TODO(francoisk777@gmail.com): Change the following two statements once
// SequencedWorkerPool supports non-zero delays.
- DCHECK_EQ(delay.InMillisecondsRoundedUp(), 0)
+ DCHECK_EQ(delay_ms, 0)
<< "SequencedWorkerPoolSequencedTaskRunner does not yet support non-zero"
" delays";
return pool_->PostSequencedWorkerTaskWithShutdownBehavior(
token_, from_here, task, shutdown_behavior_);
}
+bool SequencedWorkerPoolSequencedTaskRunner::PostDelayedTaskAssertZeroDelay(
+ const tracked_objects::Location& from_here,
+ const Closure& task,
+ TimeDelta delay) {
+ return PostDelayedTaskAssertZeroDelay(from_here,
+ task,
+ delay.InMillisecondsRoundedUp());
+}
+
} // namespace
// Worker ---------------------------------------------------------------------
@@ -976,6 +1033,15 @@ bool SequencedWorkerPool::PostSequencedWorkerTaskWithShutdownBehavior(
bool SequencedWorkerPool::PostDelayedTask(
const tracked_objects::Location& from_here,
const Closure& task,
+ int64 delay_ms) {
+ // TODO(akalin): Add support for non-zero delays.
+ DCHECK_EQ(delay_ms, 0);
+ return PostWorkerTask(from_here, task);
+}
+
+bool SequencedWorkerPool::PostDelayedTask(
+ const tracked_objects::Location& from_here,
+ const Closure& task,
TimeDelta delay) {
// TODO(akalin): Add support for non-zero delays.
DCHECK_EQ(delay.InMillisecondsRoundedUp(), 0);