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

Side by Side Diff: base/threading/sequenced_worker_pool.cc

Issue 148613014: CC: Add 'cc-benchmark' traces for minimal tracing in benchmarks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minimum overhead toplevel tracing. Created 6 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/threading/sequenced_worker_pool.h" 5 #include "base/threading/sequenced_worker_pool.h"
6 6
7 #include <list> 7 #include <list>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 if (max_blocking_tasks_after_shutdown_ <= 0) { 586 if (max_blocking_tasks_after_shutdown_ <= 0) {
587 DLOG(WARNING) << "BLOCK_SHUTDOWN task disallowed"; 587 DLOG(WARNING) << "BLOCK_SHUTDOWN task disallowed";
588 return false; 588 return false;
589 } 589 }
590 max_blocking_tasks_after_shutdown_ -= 1; 590 max_blocking_tasks_after_shutdown_ -= 1;
591 } 591 }
592 592
593 // The trace_id is used for identifying the task in about:tracing. 593 // The trace_id is used for identifying the task in about:tracing.
594 sequenced.trace_id = trace_id_++; 594 sequenced.trace_id = trace_id_++;
595 595
596 TRACE_EVENT_FLOW_BEGIN0(TRACE_DISABLED_BY_DEFAULT("toplevel.flow"), 596 TRACE_EVENT_FLOW_BEGIN0(TRACE_DISABLED_BY_DEFAULT("task.flow"),
597 "SequencedWorkerPool::PostTask", 597 "SequencedWorkerPool::PostTask",
598 TRACE_ID_MANGLE(GetTaskTraceID(sequenced, static_cast<void*>(this)))); 598 TRACE_ID_MANGLE(GetTaskTraceID(sequenced, static_cast<void*>(this))));
599 599
600 sequenced.sequence_task_number = LockedGetNextSequenceTaskNumber(); 600 sequenced.sequence_task_number = LockedGetNextSequenceTaskNumber();
601 601
602 // Now that we have the lock, apply the named token rules. 602 // Now that we have the lock, apply the named token rules.
603 if (optional_token_name) 603 if (optional_token_name)
604 sequenced.sequence_token_id = LockedGetNamedTokenID(*optional_token_name); 604 sequenced.sequence_token_id = LockedGetNamedTokenID(*optional_token_name);
605 605
606 pending_tasks_.insert(sequenced); 606 pending_tasks_.insert(sequenced);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 720
721 HandleCleanup(); 721 HandleCleanup();
722 722
723 // See GetWork for what delete_these_outside_lock is doing. 723 // See GetWork for what delete_these_outside_lock is doing.
724 SequencedTask task; 724 SequencedTask task;
725 TimeDelta wait_time; 725 TimeDelta wait_time;
726 std::vector<Closure> delete_these_outside_lock; 726 std::vector<Closure> delete_these_outside_lock;
727 GetWorkStatus status = 727 GetWorkStatus status =
728 GetWork(&task, &wait_time, &delete_these_outside_lock); 728 GetWork(&task, &wait_time, &delete_these_outside_lock);
729 if (status == GET_WORK_FOUND) { 729 if (status == GET_WORK_FOUND) {
730 TRACE_EVENT_FLOW_END0(TRACE_DISABLED_BY_DEFAULT("toplevel.flow"), 730 TRACE_EVENT_FLOW_END0(TRACE_DISABLED_BY_DEFAULT("task.flow"),
731 "SequencedWorkerPool::PostTask", 731 "SequencedWorkerPool::PostTask",
732 TRACE_ID_MANGLE(GetTaskTraceID(task, static_cast<void*>(this)))); 732 TRACE_ID_MANGLE(GetTaskTraceID(task, static_cast<void*>(this))));
733 TRACE_EVENT2("toplevel", "SequencedWorkerPool::ThreadLoop", 733 TRACE_EVENT2("task", "SequencedWorkerPool::ThreadLoop",
734 "src_file", task.posted_from.file_name(), 734 "src_file", task.posted_from.file_name(),
735 "src_func", task.posted_from.function_name()); 735 "src_func", task.posted_from.function_name());
736 int new_thread_id = WillRunWorkerTask(task); 736 int new_thread_id = WillRunWorkerTask(task);
737 { 737 {
738 AutoUnlock unlock(lock_); 738 AutoUnlock unlock(lock_);
739 // There may be more work available, so wake up another 739 // There may be more work available, so wake up another
740 // worker thread. (Technically not required, since we 740 // worker thread. (Technically not required, since we
741 // already get a signal for each new task, but it doesn't 741 // already get a signal for each new task, but it doesn't
742 // hurt.) 742 // hurt.)
743 SignalHasWork(); 743 SignalHasWork();
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
1280 void SequencedWorkerPool::Shutdown(int max_new_blocking_tasks_after_shutdown) { 1280 void SequencedWorkerPool::Shutdown(int max_new_blocking_tasks_after_shutdown) {
1281 DCHECK(constructor_message_loop_->BelongsToCurrentThread()); 1281 DCHECK(constructor_message_loop_->BelongsToCurrentThread());
1282 inner_->Shutdown(max_new_blocking_tasks_after_shutdown); 1282 inner_->Shutdown(max_new_blocking_tasks_after_shutdown);
1283 } 1283 }
1284 1284
1285 bool SequencedWorkerPool::IsShutdownInProgress() { 1285 bool SequencedWorkerPool::IsShutdownInProgress() {
1286 return inner_->IsShutdownInProgress(); 1286 return inner_->IsShutdownInProgress();
1287 } 1287 }
1288 1288
1289 } // namespace base 1289 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698