blob: fb64c85d11de86e2448d914bfdaf250708505d71 [file] [log] [blame]
license.botf003cfe2008-08-24 09:55:55 +09001// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit3f4a7322008-07-27 06:49:38 +09004
5#include "base/worker_pool.h"
6
darin@google.comd3b9a192008-07-30 13:38:38 +09007#include "base/task.h"
initial.commit3f4a7322008-07-27 06:49:38 +09008
9namespace {
10
11DWORD CALLBACK WorkItemCallback(void* param) {
12 Task* task = static_cast<Task*>(param);
13 task->Run();
darin@google.comd3b9a192008-07-30 13:38:38 +090014 delete task;
initial.commit3f4a7322008-07-27 06:49:38 +090015 return 0;
16}
17
18} // namespace
19
darin@google.comd3b9a192008-07-30 13:38:38 +090020bool WorkerPool::PostTask(const tracked_objects::Location& from_here,
21 Task* task, bool task_is_slow) {
22 task->SetBirthPlace(from_here);
23
initial.commit3f4a7322008-07-27 06:49:38 +090024 ULONG flags = 0;
darin@google.comd3b9a192008-07-30 13:38:38 +090025 if (task_is_slow)
initial.commit3f4a7322008-07-27 06:49:38 +090026 flags |= WT_EXECUTELONGFUNCTION;
27
28 if (!QueueUserWorkItem(WorkItemCallback, task, flags)) {
29 DLOG(ERROR) << "QueueUserWorkItem failed: " << GetLastError();
darin@google.comd3b9a192008-07-30 13:38:38 +090030 delete task;
initial.commit3f4a7322008-07-27 06:49:38 +090031 return false;
32 }
33
34 return true;
35}
license.botf003cfe2008-08-24 09:55:55 +090036