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

Unified Diff: base/test/sequenced_task_runner_test_template.cc

Issue 9663075: Implementation of SequencedTaskRunner based on SequencedWorkerPool. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 9 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/test/sequenced_task_runner_test_template.cc
===================================================================
--- base/test/sequenced_task_runner_test_template.cc (revision 0)
+++ base/test/sequenced_task_runner_test_template.cc (revision 0)
@@ -0,0 +1,75 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/test/sequenced_task_runner_test_template.h"
+
+namespace base {
+
+namespace internal {
+
+SequencedTaskTracker::SequencedTaskTracker() : next_post_i_(0) {
+}
+
+SequencedTaskTracker::~SequencedTaskTracker() {
+}
+
+int SequencedTaskTracker::GetNextPostOrdinal() {
+ return next_post_i_++;
+}
+
+void SequencedTaskTracker::TaskPosted(int i) {
+ AutoLock lock(phase_lock_);
+ phases_.push_back(TaskPhase(i, TaskPhase::POST));
+}
+
+void SequencedTaskTracker::TaskStarted(int i) {
+ AutoLock lock(phase_lock_);
+ phases_.push_back(TaskPhase(i, TaskPhase::START));
+}
+
+void SequencedTaskTracker::TaskEnded(int i) {
+ AutoLock lock(phase_lock_);
+ phases_.push_back(TaskPhase(i, TaskPhase::END));
+}
+
+const std::vector<SequencedTaskTracker::TaskPhase>&
+SequencedTaskTracker::GetTaskPhases() const {
+ return phases_;
+}
+
+void SequencedTaskTracker::FastTask(int i) {
+ TaskStarted(i);
+ base::PlatformThread::YieldCurrentThread();
akalin 2012/03/20 22:16:08 remove this line -- it shouldn't be needed and its
Francois 2012/03/26 09:33:21 Done.
+ TaskEnded(i);
+}
+
+void SequencedTaskTracker::SlowTask(int i) {
+ TaskStarted(i);
+ base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1));
+ TaskEnded(i);
+}
+
+void SequencedTaskTracker::PostFastNonNestableFromSlowNonNestable(
+ scoped_refptr<SequencedTaskRunner> task_runner,
+ const int i,
+ const int child_count) {
+
+ TaskStarted(i);
+
+ for (int j = 0; j < child_count; ++j) {
+ AutoLock phase_lock(phase_lock_);
+ const int child_i = GetNextPostOrdinal();
+ Closure task = Bind(&SequencedTaskTracker::FastTask,
+ this,
+ child_i);
+ phases_.push_back(TaskPhase(child_i, TaskPhase::POST));
+ task_runner->PostNonNestableTask(FROM_HERE, task);
+ }
+
+ TaskEnded(i);
+}
+
+} // namespace internal
+
+} // namespace base
Property changes on: base/test/sequenced_task_runner_test_template.cc
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698