license.bot | f003cfe | 2008-08-24 09:55:55 +0900 | [diff] [blame^] | 1 | // 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.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 4 | |
| 5 | #include "base/worker_pool.h" |
| 6 | |
darin@google.com | d3b9a19 | 2008-07-30 13:38:38 +0900 | [diff] [blame] | 7 | #include "base/task.h" |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 8 | |
| 9 | namespace { |
| 10 | |
| 11 | DWORD CALLBACK WorkItemCallback(void* param) { |
| 12 | Task* task = static_cast<Task*>(param); |
| 13 | task->Run(); |
darin@google.com | d3b9a19 | 2008-07-30 13:38:38 +0900 | [diff] [blame] | 14 | delete task; |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 15 | return 0; |
| 16 | } |
| 17 | |
| 18 | } // namespace |
| 19 | |
darin@google.com | d3b9a19 | 2008-07-30 13:38:38 +0900 | [diff] [blame] | 20 | bool WorkerPool::PostTask(const tracked_objects::Location& from_here, |
| 21 | Task* task, bool task_is_slow) { |
| 22 | task->SetBirthPlace(from_here); |
| 23 | |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 24 | ULONG flags = 0; |
darin@google.com | d3b9a19 | 2008-07-30 13:38:38 +0900 | [diff] [blame] | 25 | if (task_is_slow) |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 26 | flags |= WT_EXECUTELONGFUNCTION; |
| 27 | |
| 28 | if (!QueueUserWorkItem(WorkItemCallback, task, flags)) { |
| 29 | DLOG(ERROR) << "QueueUserWorkItem failed: " << GetLastError(); |
darin@google.com | d3b9a19 | 2008-07-30 13:38:38 +0900 | [diff] [blame] | 30 | delete task; |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 31 | return false; |
| 32 | } |
| 33 | |
| 34 | return true; |
| 35 | } |
license.bot | f003cfe | 2008-08-24 09:55:55 +0900 | [diff] [blame^] | 36 | |