summaryrefslogtreecommitdiffstats
path: root/base/threading
diff options
context:
space:
mode:
Diffstat (limited to 'base/threading')
-rw-r--r--base/threading/thread.cc2
-rw-r--r--base/threading/worker_pool_posix.cc19
-rw-r--r--base/threading/worker_pool_posix.h6
-rw-r--r--base/threading/worker_pool_win.cc24
4 files changed, 32 insertions, 19 deletions
diff --git a/base/threading/thread.cc b/base/threading/thread.cc
index d49f247..2a8d999 100644
--- a/base/threading/thread.cc
+++ b/base/threading/thread.cc
@@ -152,7 +152,9 @@ void Thread::ThreadMain() {
ANNOTATE_THREAD_NAME(name_.c_str()); // Tell the name to race detector.
message_loop.set_thread_name(name_);
message_loop_ = &message_loop;
+#if defined(TRACK_ALL_TASK_OBJECTS)
tracked_objects::ThreadData::InitializeThreadContext(name_);
+#endif // TRACK_ALL_TASK_OBJECTS
// Let the thread do extra initialization.
// Let's do this before signaling we are started.
diff --git a/base/threading/worker_pool_posix.cc b/base/threading/worker_pool_posix.cc
index 917565d..41fa01a 100644
--- a/base/threading/worker_pool_posix.cc
+++ b/base/threading/worker_pool_posix.cc
@@ -88,14 +88,15 @@ void WorkerThread::ThreadMain() {
"src_file", pending_task.posted_from.file_name(),
"src_func", pending_task.posted_from.function_name());
- tracked_objects::TrackedTime start_time =
- tracked_objects::ThreadData::Now();
-
+#if defined(TRACK_ALL_TASK_OBJECTS)
+ TimeTicks start_of_run = tracked_objects::ThreadData::Now();
+#endif // defined(TRACK_ALL_TASK_OBJECTS)
pending_task.task.Run();
-
- tracked_objects::ThreadData::TallyRunOnWorkerThreadIfTracking(
- pending_task.birth_tally, pending_task.time_posted,
- start_time, tracked_objects::ThreadData::Now());
+#if defined(TRACK_ALL_TASK_OBJECTS)
+ tracked_objects::ThreadData::TallyADeathIfActive(pending_task.post_births,
+ pending_task.time_posted, TimeTicks(), start_of_run,
+ tracked_objects::ThreadData::Now());
+#endif // defined(TRACK_ALL_TASK_OBJECTS)
}
// The WorkerThread is non-joinable, so it deletes itself.
@@ -121,8 +122,10 @@ PosixDynamicThreadPool::PendingTask::PendingTask(
const base::Closure& task)
: posted_from(posted_from),
task(task) {
- birth_tally = tracked_objects::ThreadData::TallyABirthIfActive(posted_from);
+#if defined(TRACK_ALL_TASK_OBJECTS)
+ post_births = tracked_objects::ThreadData::TallyABirthIfActive(posted_from);
time_posted = tracked_objects::ThreadData::Now();
+#endif // defined(TRACK_ALL_TASK_OBJECTS)
}
PosixDynamicThreadPool::PendingTask::~PendingTask() {
diff --git a/base/threading/worker_pool_posix.h b/base/threading/worker_pool_posix.h
index 2cc1150..c0a60cc 100644
--- a/base/threading/worker_pool_posix.h
+++ b/base/threading/worker_pool_posix.h
@@ -53,11 +53,13 @@ class BASE_EXPORT PosixDynamicThreadPool
const base::Closure& task);
~PendingTask();
+#if defined(TRACK_ALL_TASK_OBJECTS)
// Counter for location where the Closure was posted from.
- tracked_objects::Births* birth_tally;
+ tracked_objects::Births* post_births;
// Time the task was posted.
- tracked_objects::TrackedTime time_posted;
+ TimeTicks time_posted;
+#endif // defined(TRACK_ALL_TASK_OBJECTS)
const tracked_objects::Location posted_from;
diff --git a/base/threading/worker_pool_win.cc b/base/threading/worker_pool_win.cc
index b73cabd..0cd3d96 100644
--- a/base/threading/worker_pool_win.cc
+++ b/base/threading/worker_pool_win.cc
@@ -20,15 +20,19 @@ struct PendingTask {
const base::Closure& task)
: posted_from(posted_from),
task(task) {
- birth_tally = tracked_objects::ThreadData::TallyABirthIfActive(posted_from);
+#if defined(TRACK_ALL_TASK_OBJECTS)
+ post_births = tracked_objects::ThreadData::TallyABirthIfActive(posted_from);
time_posted = tracked_objects::ThreadData::Now();
+#endif // defined(TRACK_ALL_TASK_OBJECTS)
}
+#if defined(TRACK_ALL_TASK_OBJECTS)
// Counter for location where the Closure was posted from.
- tracked_objects::Births* birth_tally;
+ tracked_objects::Births* post_births;
// Time the task was posted.
- tracked_objects::TrackedTime time_posted;
+ TimeTicks time_posted;
+#endif // defined(TRACK_ALL_TASK_OBJECTS)
// The site this PendingTask was posted from.
tracked_objects::Location posted_from;
@@ -43,13 +47,15 @@ DWORD CALLBACK WorkItemCallback(void* param) {
"src_file", pending_task->posted_from.file_name(),
"src_func", pending_task->posted_from.function_name());
- tracked_objects::TrackedTime start_time = tracked_objects::ThreadData::Now();
-
+#if defined(TRACK_ALL_TASK_OBJECTS)
+ TimeTicks start_of_run = tracked_objects::ThreadData::Now();
+#endif // defined(TRACK_ALL_TASK_OBJECTS)
pending_task->task.Run();
-
- tracked_objects::ThreadData::TallyRunOnWorkerThreadIfTracking(
- pending_task->birth_tally, pending_task->time_posted,
- start_time, tracked_objects::ThreadData::Now());
+#if defined(TRACK_ALL_TASK_OBJECTS)
+ tracked_objects::ThreadData::TallyADeathIfActive(pending_task->post_births,
+ pending_task->time_posted, TimeTicks::TimeTicks(), start_of_run,
+ tracked_objects::ThreadData::Now());
+#endif // defined(TRACK_ALL_TASK_OBJECTS)
delete pending_task;
return 0;