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

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

Issue 148173011: Make flow event traces disabled-by-default, and rename "ipc" and "task" categories to "toplevel" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Replace "ipc" and "task" categories with toplevel. 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 | Annotate | Revision Log
« no previous file with comments | « base/message_loop/message_pump_gtk.cc ('k') | base/threading/worker_pool_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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("task", "SequencedWorkerPool::PostTask", 596 TRACE_EVENT_FLOW_BEGIN0(TRACE_DISABLED_BY_DEFAULT("toplevel.flow"),
597 "SequencedWorkerPool::PostTask",
597 TRACE_ID_MANGLE(GetTaskTraceID(sequenced, static_cast<void*>(this)))); 598 TRACE_ID_MANGLE(GetTaskTraceID(sequenced, static_cast<void*>(this))));
598 599
599 sequenced.sequence_task_number = LockedGetNextSequenceTaskNumber(); 600 sequenced.sequence_task_number = LockedGetNextSequenceTaskNumber();
600 601
601 // Now that we have the lock, apply the named token rules. 602 // Now that we have the lock, apply the named token rules.
602 if (optional_token_name) 603 if (optional_token_name)
603 sequenced.sequence_token_id = LockedGetNamedTokenID(*optional_token_name); 604 sequenced.sequence_token_id = LockedGetNamedTokenID(*optional_token_name);
604 605
605 pending_tasks_.insert(sequenced); 606 pending_tasks_.insert(sequenced);
606 if (shutdown_behavior == BLOCK_SHUTDOWN) 607 if (shutdown_behavior == BLOCK_SHUTDOWN)
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 720
720 HandleCleanup(); 721 HandleCleanup();
721 722
722 // See GetWork for what delete_these_outside_lock is doing. 723 // See GetWork for what delete_these_outside_lock is doing.
723 SequencedTask task; 724 SequencedTask task;
724 TimeDelta wait_time; 725 TimeDelta wait_time;
725 std::vector<Closure> delete_these_outside_lock; 726 std::vector<Closure> delete_these_outside_lock;
726 GetWorkStatus status = 727 GetWorkStatus status =
727 GetWork(&task, &wait_time, &delete_these_outside_lock); 728 GetWork(&task, &wait_time, &delete_these_outside_lock);
728 if (status == GET_WORK_FOUND) { 729 if (status == GET_WORK_FOUND) {
729 TRACE_EVENT_FLOW_END0("task", "SequencedWorkerPool::PostTask", 730 TRACE_EVENT_FLOW_END0(TRACE_DISABLED_BY_DEFAULT("toplevel.flow"),
731 "SequencedWorkerPool::PostTask",
730 TRACE_ID_MANGLE(GetTaskTraceID(task, static_cast<void*>(this)))); 732 TRACE_ID_MANGLE(GetTaskTraceID(task, static_cast<void*>(this))));
731 TRACE_EVENT2("task", "SequencedWorkerPool::ThreadLoop", 733 TRACE_EVENT2("toplevel", "SequencedWorkerPool::ThreadLoop",
732 "src_file", task.posted_from.file_name(), 734 "src_file", task.posted_from.file_name(),
733 "src_func", task.posted_from.function_name()); 735 "src_func", task.posted_from.function_name());
734 int new_thread_id = WillRunWorkerTask(task); 736 int new_thread_id = WillRunWorkerTask(task);
735 { 737 {
736 AutoUnlock unlock(lock_); 738 AutoUnlock unlock(lock_);
737 // There may be more work available, so wake up another 739 // There may be more work available, so wake up another
738 // worker thread. (Technically not required, since we 740 // worker thread. (Technically not required, since we
739 // 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
740 // hurt.) 742 // hurt.)
741 SignalHasWork(); 743 SignalHasWork();
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 void SequencedWorkerPool::Shutdown(int max_new_blocking_tasks_after_shutdown) { 1280 void SequencedWorkerPool::Shutdown(int max_new_blocking_tasks_after_shutdown) {
1279 DCHECK(constructor_message_loop_->BelongsToCurrentThread()); 1281 DCHECK(constructor_message_loop_->BelongsToCurrentThread());
1280 inner_->Shutdown(max_new_blocking_tasks_after_shutdown); 1282 inner_->Shutdown(max_new_blocking_tasks_after_shutdown);
1281 } 1283 }
1282 1284
1283 bool SequencedWorkerPool::IsShutdownInProgress() { 1285 bool SequencedWorkerPool::IsShutdownInProgress() {
1284 return inner_->IsShutdownInProgress(); 1286 return inner_->IsShutdownInProgress();
1285 } 1287 }
1286 1288
1287 } // namespace base 1289 } // namespace base
OLDNEW
« no previous file with comments | « base/message_loop/message_pump_gtk.cc ('k') | base/threading/worker_pool_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698