summaryrefslogtreecommitdiffstats
path: root/base/threading
diff options
context:
space:
mode:
Diffstat (limited to 'base/threading')
-rw-r--r--base/threading/sequenced_worker_pool.cc10
-rw-r--r--base/threading/worker_pool_posix.cc8
-rw-r--r--base/threading/worker_pool_win.cc11
3 files changed, 16 insertions, 13 deletions
diff --git a/base/threading/sequenced_worker_pool.cc b/base/threading/sequenced_worker_pool.cc
index 532f26e..38b2998 100644
--- a/base/threading/sequenced_worker_pool.cc
+++ b/base/threading/sequenced_worker_pool.cc
@@ -755,13 +755,13 @@ void SequencedWorkerPool::Inner::ThreadLoop(Worker* this_worker) {
this_worker->set_running_task_info(
SequenceToken(task.sequence_token_id), task.shutdown_behavior);
- tracked_objects::TrackedTime start_time =
- tracked_objects::ThreadData::NowForStartOfRun(task.birth_tally);
-
+ tracked_objects::ThreadData::PrepareForStartOfRun(task.birth_tally);
+ tracked_objects::TaskStopwatch stopwatch;
task.task.Run();
+ stopwatch.Stop();
- tracked_objects::ThreadData::TallyRunOnNamedThreadIfTracking(task,
- start_time, tracked_objects::ThreadData::NowForEndOfRun());
+ tracked_objects::ThreadData::TallyRunOnNamedThreadIfTracking(
+ task, stopwatch);
// Make sure our task is erased outside the lock for the
// same reason we do this with delete_these_oustide_lock.
diff --git a/base/threading/worker_pool_posix.cc b/base/threading/worker_pool_posix.cc
index f00d799..167d20f 100644
--- a/base/threading/worker_pool_posix.cc
+++ b/base/threading/worker_pool_posix.cc
@@ -95,14 +95,14 @@ void WorkerThread::ThreadMain() {
"src_file", pending_task.posted_from.file_name(),
"src_func", pending_task.posted_from.function_name());
- TrackedTime start_time =
- tracked_objects::ThreadData::NowForStartOfRun(pending_task.birth_tally);
-
+ tracked_objects::ThreadData::PrepareForStartOfRun(pending_task.birth_tally);
+ tracked_objects::TaskStopwatch stopwatch;
pending_task.task.Run();
+ stopwatch.Stop();
tracked_objects::ThreadData::TallyRunOnWorkerThreadIfTracking(
pending_task.birth_tally, TrackedTime(pending_task.time_posted),
- start_time, tracked_objects::ThreadData::NowForEndOfRun());
+ stopwatch);
}
// The WorkerThread is non-joinable, so it deletes itself.
diff --git a/base/threading/worker_pool_win.cc b/base/threading/worker_pool_win.cc
index fa11dc5..8fc7324 100644
--- a/base/threading/worker_pool_win.cc
+++ b/base/threading/worker_pool_win.cc
@@ -25,17 +25,20 @@ 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::NowForStartOfRun(pending_task->birth_tally);
+ tracked_objects::ThreadData::PrepareForStartOfRun(pending_task->birth_tally);
g_worker_pool_running_on_this_thread.Get().Set(true);
+
+ tracked_objects::TaskStopwatch stopwatch;
pending_task->task.Run();
+ stopwatch.Stop();
+
g_worker_pool_running_on_this_thread.Get().Set(false);
tracked_objects::ThreadData::TallyRunOnWorkerThreadIfTracking(
pending_task->birth_tally,
- tracked_objects::TrackedTime(pending_task->time_posted), start_time,
- tracked_objects::ThreadData::NowForEndOfRun());
+ tracked_objects::TrackedTime(pending_task->time_posted),
+ stopwatch);
delete pending_task;
return 0;