OLD | NEW |
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" |
(...skipping 19 matching lines...) Expand all Loading... |
30 g_worker_pool_running_on_this_thread.Get().Set(true); | 30 g_worker_pool_running_on_this_thread.Get().Set(true); |
31 | 31 |
32 tracked_objects::TaskStopwatch stopwatch; | 32 tracked_objects::TaskStopwatch stopwatch; |
33 stopwatch.Start(); | 33 stopwatch.Start(); |
34 pending_task->task.Run(); | 34 pending_task->task.Run(); |
35 stopwatch.Stop(); | 35 stopwatch.Stop(); |
36 | 36 |
37 g_worker_pool_running_on_this_thread.Get().Set(false); | 37 g_worker_pool_running_on_this_thread.Get().Set(false); |
38 | 38 |
39 tracked_objects::ThreadData::TallyRunOnWorkerThreadIfTracking( | 39 tracked_objects::ThreadData::TallyRunOnWorkerThreadIfTracking( |
40 pending_task->birth_tally, | 40 pending_task->birth_tally, pending_task->time_posted, stopwatch); |
41 tracked_objects::TrackedTime(pending_task->time_posted), | |
42 stopwatch); | |
43 | 41 |
44 delete pending_task; | 42 delete pending_task; |
45 return 0; | 43 return 0; |
46 } | 44 } |
47 | 45 |
48 // Takes ownership of |pending_task| | 46 // Takes ownership of |pending_task| |
49 bool PostTaskInternal(PendingTask* pending_task, bool task_is_slow) { | 47 bool PostTaskInternal(PendingTask* pending_task, bool task_is_slow) { |
50 ULONG flags = 0; | 48 ULONG flags = 0; |
51 if (task_is_slow) | 49 if (task_is_slow) |
52 flags |= WT_EXECUTELONGFUNCTION; | 50 flags |= WT_EXECUTELONGFUNCTION; |
(...skipping 15 matching lines...) Expand all Loading... |
68 PendingTask* pending_task = new PendingTask(from_here, task); | 66 PendingTask* pending_task = new PendingTask(from_here, task); |
69 return PostTaskInternal(pending_task, task_is_slow); | 67 return PostTaskInternal(pending_task, task_is_slow); |
70 } | 68 } |
71 | 69 |
72 // static | 70 // static |
73 bool WorkerPool::RunsTasksOnCurrentThread() { | 71 bool WorkerPool::RunsTasksOnCurrentThread() { |
74 return g_worker_pool_running_on_this_thread.Get().Get(); | 72 return g_worker_pool_running_on_this_thread.Get().Get(); |
75 } | 73 } |
76 | 74 |
77 } // namespace base | 75 } // namespace base |
OLD | NEW |