summaryrefslogtreecommitdiffstats
path: root/base/threading/worker_pool_win.cc
diff options
context:
space:
mode:
Diffstat (limited to 'base/threading/worker_pool_win.cc')
-rw-r--r--base/threading/worker_pool_win.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/base/threading/worker_pool_win.cc b/base/threading/worker_pool_win.cc
index 86463c7..1e8be26 100644
--- a/base/threading/worker_pool_win.cc
+++ b/base/threading/worker_pool_win.cc
@@ -9,12 +9,16 @@
#include "base/debug/trace_event.h"
#include "base/logging.h"
#include "base/pending_task.h"
+#include "base/threading/thread_local.h"
#include "base/tracked_objects.h"
namespace base {
namespace {
+base::LazyInstance<ThreadLocalBoolean>::Leaky
+ g_worker_pool_running_on_this_thread = LAZY_INSTANCE_INITIALIZER;
+
DWORD CALLBACK WorkItemCallback(void* param) {
PendingTask* pending_task = static_cast<PendingTask*>(param);
TRACE_EVENT2("task", "WorkItemCallback::Run",
@@ -24,7 +28,9 @@ DWORD CALLBACK WorkItemCallback(void* param) {
tracked_objects::TrackedTime start_time =
tracked_objects::ThreadData::NowForStartOfRun(pending_task->birth_tally);
+ g_worker_pool_running_on_this_thread.Get().Set(true);
pending_task->task.Run();
+ g_worker_pool_running_on_this_thread.Get().Set(false);
tracked_objects::ThreadData::TallyRunOnWorkerThreadIfTracking(
pending_task->birth_tally,
@@ -52,10 +58,16 @@ bool PostTaskInternal(PendingTask* pending_task, bool task_is_slow) {
} // namespace
+// static
bool WorkerPool::PostTask(const tracked_objects::Location& from_here,
const base::Closure& task, bool task_is_slow) {
PendingTask* pending_task = new PendingTask(from_here, task);
return PostTaskInternal(pending_task, task_is_slow);
}
+// static
+bool WorkerPool::RunsTasksOnCurrentThread() {
+ return g_worker_pool_running_on_this_thread.Get().Get();
+}
+
} // namespace base