Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: base/worker_pool_linux.cc

Issue 39081: Split worker_pool.cc into worker_pool_linux.cc and worker_pool_win.cc (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/worker_pool.cc ('k') | base/worker_pool_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/worker_pool.h" 5 #include "base/worker_pool.h"
6 6
7 #include "base/task.h" 7 #include "base/task.h"
8 8
9 // TODO(dsh): Split this file into worker_pool_win.cc and worker_pool_posix.cc.
10 #if defined(OS_WIN)
11
12 namespace {
13
14 DWORD CALLBACK WorkItemCallback(void* param) {
15 Task* task = static_cast<Task*>(param);
16 task->Run();
17 delete task;
18 return 0;
19 }
20
21 } // namespace
22
23 bool WorkerPool::PostTask(const tracked_objects::Location& from_here,
24 Task* task, bool task_is_slow) {
25 task->SetBirthPlace(from_here);
26
27 ULONG flags = 0;
28 if (task_is_slow)
29 flags |= WT_EXECUTELONGFUNCTION;
30
31 if (!QueueUserWorkItem(WorkItemCallback, task, flags)) {
32 DLOG(ERROR) << "QueueUserWorkItem failed: " << GetLastError();
33 delete task;
34 return false;
35 }
36
37 return true;
38 }
39
40 #elif defined(OS_LINUX)
41
42 namespace { 9 namespace {
43 10
44 void* PThreadCallback(void* param) { 11 void* PThreadCallback(void* param) {
45 Task* task = static_cast<Task*>(param); 12 Task* task = static_cast<Task*>(param);
46 task->Run(); 13 task->Run();
47 delete task; 14 delete task;
48 return 0; 15 return 0;
49 } 16 }
50 17
51 } // namespace 18 } // namespace
(...skipping 14 matching lines...) Expand all
66 int err = pthread_create(&thread, &attr, PThreadCallback, task); 33 int err = pthread_create(&thread, &attr, PThreadCallback, task);
67 pthread_attr_destroy(&attr); 34 pthread_attr_destroy(&attr);
68 if (err) { 35 if (err) {
69 DLOG(ERROR) << "pthread_create failed: " << err; 36 DLOG(ERROR) << "pthread_create failed: " << err;
70 delete task; 37 delete task;
71 return false; 38 return false;
72 } 39 }
73 40
74 return true; 41 return true;
75 } 42 }
76
77 #endif // OS_LINUX
OLDNEW
« no previous file with comments | « base/worker_pool.cc ('k') | base/worker_pool_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698