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

Unified Diff: native_client_sdk/src/libraries/sdk_util/thread_pool.cc

Issue 18644009: [NaCl SDK] Upate atomic ops in nacl_io (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add declartions for newval and oldval 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 side-by-side diff with in-line comments
Download patch
Index: native_client_sdk/src/libraries/sdk_util/thread_pool.cc
diff --git a/native_client_sdk/src/libraries/sdk_util/thread_pool.cc b/native_client_sdk/src/libraries/sdk_util/thread_pool.cc
index e7d2e5cb6b295e6f8ce3fcc4599453073a41b898..1a2d2b8d29218a7006077cb053cf0402e271cba9 100644
--- a/native_client_sdk/src/libraries/sdk_util/thread_pool.cc
+++ b/native_client_sdk/src/libraries/sdk_util/thread_pool.cc
@@ -60,15 +60,7 @@ void ThreadPool::Setup(int counter, WorkFunction work, void *data) {
// Return decremented task counter. This function
// can be called from multiple threads at any given time.
int ThreadPool::DecCounter() {
-#if defined(__native_client__)
- // Use fast atomic sub & fetch.
- return __sync_sub_and_fetch(&counter_, 1);
-#else
- // Fallback to a more platform independent pthread mutex via AutoLock.
- static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
- AutoLock lock(&mutex);
- return --counter_;
-#endif
+ return AtomicAddFetch(&counter_, 1);
nfullagar1 2013/07/18 00:18:06 This should return the decremented task counter, b
}
// Set exit flag, post and join all the threads in the pool. This function is
« no previous file with comments | « native_client_sdk/src/libraries/sdk_util/thread_pool.h ('k') | native_client_sdk/src/libraries/sdk_util/thread_safe_queue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698