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

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

Issue 445413003: Creating a framework for suppressing pollution of the profiler data (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing unit tests again. Created 6 years, 3 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/threading/worker_pool_posix.cc ('k') | base/tracked_objects.h » ('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/worker_pool.h" 5 #include "base/threading/worker_pool.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/pending_task.h" 11 #include "base/pending_task.h"
12 #include "base/threading/thread_local.h" 12 #include "base/threading/thread_local.h"
13 #include "base/tracked_objects.h" 13 #include "base/tracked_objects.h"
14 14
15 namespace base { 15 namespace base {
16 16
17 namespace { 17 namespace {
18 18
19 base::LazyInstance<ThreadLocalBoolean>::Leaky 19 base::LazyInstance<ThreadLocalBoolean>::Leaky
20 g_worker_pool_running_on_this_thread = LAZY_INSTANCE_INITIALIZER; 20 g_worker_pool_running_on_this_thread = LAZY_INSTANCE_INITIALIZER;
21 21
22 DWORD CALLBACK WorkItemCallback(void* param) { 22 DWORD CALLBACK WorkItemCallback(void* param) {
23 PendingTask* pending_task = static_cast<PendingTask*>(param); 23 PendingTask* pending_task = static_cast<PendingTask*>(param);
24 TRACE_EVENT2("toplevel", "WorkItemCallback::Run", 24 TRACE_EVENT2("toplevel", "WorkItemCallback::Run",
25 "src_file", pending_task->posted_from.file_name(), 25 "src_file", pending_task->posted_from.file_name(),
26 "src_func", pending_task->posted_from.function_name()); 26 "src_func", pending_task->posted_from.function_name());
27 27
28 tracked_objects::TrackedTime start_time = 28 tracked_objects::ThreadData::PrepareForStartOfRun(pending_task->birth_tally);
29 tracked_objects::ThreadData::NowForStartOfRun(pending_task->birth_tally);
30 29
31 g_worker_pool_running_on_this_thread.Get().Set(true); 30 g_worker_pool_running_on_this_thread.Get().Set(true);
31
32 tracked_objects::TaskStopwatch stopwatch;
32 pending_task->task.Run(); 33 pending_task->task.Run();
34 stopwatch.Stop();
35
33 g_worker_pool_running_on_this_thread.Get().Set(false); 36 g_worker_pool_running_on_this_thread.Get().Set(false);
34 37
35 tracked_objects::ThreadData::TallyRunOnWorkerThreadIfTracking( 38 tracked_objects::ThreadData::TallyRunOnWorkerThreadIfTracking(
36 pending_task->birth_tally, 39 pending_task->birth_tally,
37 tracked_objects::TrackedTime(pending_task->time_posted), start_time, 40 tracked_objects::TrackedTime(pending_task->time_posted),
38 tracked_objects::ThreadData::NowForEndOfRun()); 41 stopwatch);
39 42
40 delete pending_task; 43 delete pending_task;
41 return 0; 44 return 0;
42 } 45 }
43 46
44 // Takes ownership of |pending_task| 47 // Takes ownership of |pending_task|
45 bool PostTaskInternal(PendingTask* pending_task, bool task_is_slow) { 48 bool PostTaskInternal(PendingTask* pending_task, bool task_is_slow) {
46 ULONG flags = 0; 49 ULONG flags = 0;
47 if (task_is_slow) 50 if (task_is_slow)
48 flags |= WT_EXECUTELONGFUNCTION; 51 flags |= WT_EXECUTELONGFUNCTION;
(...skipping 15 matching lines...) Expand all
64 PendingTask* pending_task = new PendingTask(from_here, task); 67 PendingTask* pending_task = new PendingTask(from_here, task);
65 return PostTaskInternal(pending_task, task_is_slow); 68 return PostTaskInternal(pending_task, task_is_slow);
66 } 69 }
67 70
68 // static 71 // static
69 bool WorkerPool::RunsTasksOnCurrentThread() { 72 bool WorkerPool::RunsTasksOnCurrentThread() {
70 return g_worker_pool_running_on_this_thread.Get().Get(); 73 return g_worker_pool_running_on_this_thread.Get().Get();
71 } 74 }
72 75
73 } // namespace base 76 } // namespace base
OLDNEW
« no previous file with comments | « base/threading/worker_pool_posix.cc ('k') | base/tracked_objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698