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

Side by Side Diff: native_client_sdk/src/libraries/sdk_util/thread_pool.h

Issue 19717004: [NaCl SDK] Add nacl_io and sdk_util namespaces. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix bad copyright in mount_mem Created 7 years, 5 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 // Simple thread pool class 5 // Simple thread pool class
6 6
7 #ifndef LIBRARIES_SDK_UTIL_THREAD_POOL_H_ 7 #ifndef LIBRARIES_SDK_UTIL_THREAD_POOL_H_
8 #define LIBRARIES_SDK_UTIL_THREAD_POOL_H_ 8 #define LIBRARIES_SDK_UTIL_THREAD_POOL_H_
9 9
10 #include <pthread.h> 10 #include <pthread.h>
11 #include <semaphore.h> 11 #include <semaphore.h>
12 12
13 #include "sdk_util/atomicops.h" 13 #include "sdk_util/atomicops.h"
14 14
15 namespace sdk_util {
16
15 // typdef helper for work function 17 // typdef helper for work function
16 typedef void (*WorkFunction)(int task_index, void* data); 18 typedef void (*WorkFunction)(int task_index, void* data);
17 19
18 // ThreadPool is a class to manage num_threads and assign 20 // ThreadPool is a class to manage num_threads and assign
19 // them num_tasks of work at a time. Each call 21 // them num_tasks of work at a time. Each call
20 // to Dispatch(..) will block until all tasks complete. 22 // to Dispatch(..) will block until all tasks complete.
21 // If 0 is passed in for num_threads, all tasks will be 23 // If 0 is passed in for num_threads, all tasks will be
22 // issued on the dispatch thread. 24 // issued on the dispatch thread.
23 25
24 class ThreadPool { 26 class ThreadPool {
(...skipping 11 matching lines...) Expand all
36 void PostExitAndJoinAll(); 38 void PostExitAndJoinAll();
37 pthread_t* threads_; 39 pthread_t* threads_;
38 Atomic32 counter_; 40 Atomic32 counter_;
39 const int num_threads_; 41 const int num_threads_;
40 bool exiting_; 42 bool exiting_;
41 void* user_data_; 43 void* user_data_;
42 WorkFunction user_work_function_; 44 WorkFunction user_work_function_;
43 sem_t work_sem_; 45 sem_t work_sem_;
44 sem_t done_sem_; 46 sem_t done_sem_;
45 }; 47 };
48
49 } // namespace sdk_util
50
46 #endif // LIBRARIES_SDK_UTIL_THREAD_POOL_H_ 51 #endif // LIBRARIES_SDK_UTIL_THREAD_POOL_H_
47 52
OLDNEW
« no previous file with comments | « native_client_sdk/src/libraries/sdk_util/simple_lock.h ('k') | native_client_sdk/src/libraries/sdk_util/thread_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698