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/sequenced_worker_pool.h" | 5 #include "base/threading/sequenced_worker_pool.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <list> | 9 #include <list> |
10 #include <map> | 10 #include <map> |
(...skipping 17 matching lines...) Expand all Loading... | |
28 #include "base/synchronization/condition_variable.h" | 28 #include "base/synchronization/condition_variable.h" |
29 #include "base/synchronization/lock.h" | 29 #include "base/synchronization/lock.h" |
30 #include "base/task_scheduler/post_task.h" | 30 #include "base/task_scheduler/post_task.h" |
31 #include "base/task_scheduler/task_scheduler.h" | 31 #include "base/task_scheduler/task_scheduler.h" |
32 #include "base/threading/platform_thread.h" | 32 #include "base/threading/platform_thread.h" |
33 #include "base/threading/simple_thread.h" | 33 #include "base/threading/simple_thread.h" |
34 #include "base/threading/thread_local.h" | 34 #include "base/threading/thread_local.h" |
35 #include "base/threading/thread_restrictions.h" | 35 #include "base/threading/thread_restrictions.h" |
36 #include "base/threading/thread_task_runner_handle.h" | 36 #include "base/threading/thread_task_runner_handle.h" |
37 #include "base/time/time.h" | 37 #include "base/time/time.h" |
38 #include "base/trace_event/heap_profiler.h" | |
39 #include "base/trace_event/trace_event.h" | 38 #include "base/trace_event/trace_event.h" |
40 #include "base/tracked_objects.h" | 39 #include "base/tracked_objects.h" |
41 #include "base/tracking_info.h" | 40 #include "base/tracking_info.h" |
42 #include "build/build_config.h" | 41 #include "build/build_config.h" |
43 | 42 |
44 #if defined(OS_MACOSX) | 43 #if defined(OS_MACOSX) |
45 #include "base/mac/scoped_nsautorelease_pool.h" | 44 #include "base/mac/scoped_nsautorelease_pool.h" |
46 #elif defined(OS_WIN) | 45 #elif defined(OS_WIN) |
47 #include "base/win/scoped_com_initializer.h" | 46 #include "base/win/scoped_com_initializer.h" |
48 #endif | 47 #endif |
(...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
985 | 984 |
986 HandleCleanup(); | 985 HandleCleanup(); |
987 | 986 |
988 // See GetWork for what delete_these_outside_lock is doing. | 987 // See GetWork for what delete_these_outside_lock is doing. |
989 SequencedTask task; | 988 SequencedTask task; |
990 TimeDelta wait_time; | 989 TimeDelta wait_time; |
991 std::vector<Closure> delete_these_outside_lock; | 990 std::vector<Closure> delete_these_outside_lock; |
992 GetWorkStatus status = | 991 GetWorkStatus status = |
993 GetWork(&task, &wait_time, &delete_these_outside_lock); | 992 GetWork(&task, &wait_time, &delete_these_outside_lock); |
994 if (status == GET_WORK_FOUND) { | 993 if (status == GET_WORK_FOUND) { |
995 TRACE_EVENT_WITH_FLOW2(TRACE_DISABLED_BY_DEFAULT("toplevel.flow"), | 994 TRACE_TASK_EXECUTION("SequencedWorkerPool::Inner::ThreadLoop", task); |
danakj
2016/10/20 21:05:18
Is reordering these ok? They will not nest differe
fdoray
2016/10/21 12:47:59
Yes.
This new ordering is consistent with Message
| |
996 "SequencedWorkerPool::Inner::ThreadLoop", | 995 TRACE_EVENT_WITH_FLOW0(TRACE_DISABLED_BY_DEFAULT("toplevel.flow"), |
996 "SequencedWorkerPool::Inner::PostTask", | |
danakj
2016/10/20 21:05:18
This is ThreadLoop tho?
fdoray
2016/10/21 12:47:59
No.
To be consistent with MessageLoop and TaskSch
| |
997 TRACE_ID_MANGLE(GetTaskTraceID(task, static_cast<void*>(this))), | 997 TRACE_ID_MANGLE(GetTaskTraceID(task, static_cast<void*>(this))), |
998 TRACE_EVENT_FLAG_FLOW_IN, | 998 TRACE_EVENT_FLAG_FLOW_IN); |
999 "src_file", task.posted_from.file_name(), | |
1000 "src_func", task.posted_from.function_name()); | |
1001 TRACE_HEAP_PROFILER_API_SCOPED_TASK_EXECUTION task_event( | |
gab
2016/10/18 18:15:02
Why was this removed?
fdoray
2016/10/18 19:19:29
This is done by TRACE_TASK_EXECUTION https://cs.ch
| |
1002 task.posted_from.file_name()); | |
1003 int new_thread_id = WillRunWorkerTask(task); | 999 int new_thread_id = WillRunWorkerTask(task); |
1004 { | 1000 { |
1005 AutoUnlock unlock(lock_); | 1001 AutoUnlock unlock(lock_); |
1006 // There may be more work available, so wake up another | 1002 // There may be more work available, so wake up another |
1007 // worker thread. (Technically not required, since we | 1003 // worker thread. (Technically not required, since we |
1008 // already get a signal for each new task, but it doesn't | 1004 // already get a signal for each new task, but it doesn't |
1009 // hurt.) | 1005 // hurt.) |
1010 SignalHasWork(); | 1006 SignalHasWork(); |
1011 delete_these_outside_lock.clear(); | 1007 delete_these_outside_lock.clear(); |
1012 | 1008 |
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1621 bool SequencedWorkerPool::IsShutdownInProgress() { | 1617 bool SequencedWorkerPool::IsShutdownInProgress() { |
1622 return inner_->IsShutdownInProgress(); | 1618 return inner_->IsShutdownInProgress(); |
1623 } | 1619 } |
1624 | 1620 |
1625 bool SequencedWorkerPool::IsRunningSequenceOnCurrentThread( | 1621 bool SequencedWorkerPool::IsRunningSequenceOnCurrentThread( |
1626 SequenceToken sequence_token) const { | 1622 SequenceToken sequence_token) const { |
1627 return inner_->IsRunningSequenceOnCurrentThread(sequence_token); | 1623 return inner_->IsRunningSequenceOnCurrentThread(sequence_token); |
1628 } | 1624 } |
1629 | 1625 |
1630 } // namespace base | 1626 } // namespace base |
OLD | NEW |