diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-30 18:08:36 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-30 18:08:36 +0000 |
commit | ac9ba8fe1d2f2397de3d7c4cebfb3c659d226fd3 (patch) | |
tree | 7118143b15fb701d5d91de270a1af7ea431eaa8a /base/threading/worker_pool_win.cc | |
parent | b8eeb3eeba2418d9a1a7bb8429ddd5ec592298c1 (diff) | |
download | chromium_src-ac9ba8fe1d2f2397de3d7c4cebfb3c659d226fd3.zip chromium_src-ac9ba8fe1d2f2397de3d7c4cebfb3c659d226fd3.tar.gz chromium_src-ac9ba8fe1d2f2397de3d7c4cebfb3c659d226fd3.tar.bz2 |
Move some misc thread-related stuff from base to base/thread and into the base
namespace. This does not move the "hard" thread stuff (thread.h).
TEST=it compiles
BUG=none
Review URL: http://codereview.chromium.org/6079009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70315 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/threading/worker_pool_win.cc')
-rw-r--r-- | base/threading/worker_pool_win.cc | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/base/threading/worker_pool_win.cc b/base/threading/worker_pool_win.cc new file mode 100644 index 0000000..2072e52 --- /dev/null +++ b/base/threading/worker_pool_win.cc @@ -0,0 +1,40 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/threading/worker_pool.h" + +#include "base/logging.h" +#include "base/task.h" + +namespace base { + +namespace { + +DWORD CALLBACK WorkItemCallback(void* param) { + Task* task = static_cast<Task*>(param); + task->Run(); + delete task; + return 0; +} + +} // namespace + +bool WorkerPool::PostTask(const tracked_objects::Location& from_here, + Task* task, bool task_is_slow) { + task->SetBirthPlace(from_here); + + ULONG flags = 0; + if (task_is_slow) + flags |= WT_EXECUTELONGFUNCTION; + + if (!QueueUserWorkItem(WorkItemCallback, task, flags)) { + DLOG(ERROR) << "QueueUserWorkItem failed: " << GetLastError(); + delete task; + return false; + } + + return true; +} + +} // namespace base |