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. 4 5 #include "base/worker_pool.h" 6 7 #include "base/logging.h" 8 #include "base/task.h" 9 10 namespace { 11 12 DWORD CALLBACK WorkItemCallback(void* param) { 13 Task* task = static_cast<Task*>(param); 14 task->Run(); 15 delete task; 16 return 0; 17 } 18 19 } // namespace 20 21 bool WorkerPool::PostTask(const tracked_objects::Location& from_here, 22 Task* task, bool task_is_slow) { 23 task->SetBirthPlace(from_here); 24 25 ULONG flags = 0; 26 if (task_is_slow) 27 flags |= WT_EXECUTELONGFUNCTION; 28 29 if (!QueueUserWorkItem(WorkItemCallback, task, flags)) { 30 DLOG(ERROR) << "QueueUserWorkItem failed: " << GetLastError(); 31 delete task; 32 return false; 33 } 34 35 return true; 36 } 37