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

Side by Side Diff: tools/threadpool/CondVar.cpp

Issue 371853005: Move threadpool code from include/utils to tools/threadpool. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: gyp Created 6 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
« no previous file with comments | « tools/threadpool/CondVar.h ('k') | tools/threadpool/Runnable.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkCondVar.h" 8 #include "CondVar.h"
9 9
10 SkCondVar::SkCondVar() { 10 CondVar::CondVar() {
11 #ifdef SK_USE_POSIX_THREADS 11 #ifdef SK_USE_POSIX_THREADS
12 pthread_mutex_init(&fMutex, NULL /* default mutex attr */); 12 pthread_mutex_init(&fMutex, NULL /* default mutex attr */);
13 pthread_cond_init(&fCond, NULL /* default cond attr */); 13 pthread_cond_init(&fCond, NULL /* default cond attr */);
14 #elif defined(SK_BUILD_FOR_WIN32) 14 #elif defined(SK_BUILD_FOR_WIN32)
15 InitializeCriticalSection(&fCriticalSection); 15 InitializeCriticalSection(&fCriticalSection);
16 InitializeConditionVariable(&fCondition); 16 InitializeConditionVariable(&fCondition);
17 #endif 17 #endif
18 } 18 }
19 19
20 SkCondVar::~SkCondVar() { 20 CondVar::~CondVar() {
21 #ifdef SK_USE_POSIX_THREADS 21 #ifdef SK_USE_POSIX_THREADS
22 pthread_mutex_destroy(&fMutex); 22 pthread_mutex_destroy(&fMutex);
23 pthread_cond_destroy(&fCond); 23 pthread_cond_destroy(&fCond);
24 #elif defined(SK_BUILD_FOR_WIN32) 24 #elif defined(SK_BUILD_FOR_WIN32)
25 DeleteCriticalSection(&fCriticalSection); 25 DeleteCriticalSection(&fCriticalSection);
26 // No need to clean up fCondition. 26 // No need to clean up fCondition.
27 #endif 27 #endif
28 } 28 }
29 29
30 void SkCondVar::lock() { 30 void CondVar::lock() {
31 #ifdef SK_USE_POSIX_THREADS 31 #ifdef SK_USE_POSIX_THREADS
32 pthread_mutex_lock(&fMutex); 32 pthread_mutex_lock(&fMutex);
33 #elif defined(SK_BUILD_FOR_WIN32) 33 #elif defined(SK_BUILD_FOR_WIN32)
34 EnterCriticalSection(&fCriticalSection); 34 EnterCriticalSection(&fCriticalSection);
35 #endif 35 #endif
36 } 36 }
37 37
38 void SkCondVar::unlock() { 38 void CondVar::unlock() {
39 #ifdef SK_USE_POSIX_THREADS 39 #ifdef SK_USE_POSIX_THREADS
40 pthread_mutex_unlock(&fMutex); 40 pthread_mutex_unlock(&fMutex);
41 #elif defined(SK_BUILD_FOR_WIN32) 41 #elif defined(SK_BUILD_FOR_WIN32)
42 LeaveCriticalSection(&fCriticalSection); 42 LeaveCriticalSection(&fCriticalSection);
43 #endif 43 #endif
44 } 44 }
45 45
46 void SkCondVar::wait() { 46 void CondVar::wait() {
47 #ifdef SK_USE_POSIX_THREADS 47 #ifdef SK_USE_POSIX_THREADS
48 pthread_cond_wait(&fCond, &fMutex); 48 pthread_cond_wait(&fCond, &fMutex);
49 #elif defined(SK_BUILD_FOR_WIN32) 49 #elif defined(SK_BUILD_FOR_WIN32)
50 SleepConditionVariableCS(&fCondition, &fCriticalSection, INFINITE); 50 SleepConditionVariableCS(&fCondition, &fCriticalSection, INFINITE);
51 #endif 51 #endif
52 } 52 }
53 53
54 void SkCondVar::signal() { 54 void CondVar::signal() {
55 #ifdef SK_USE_POSIX_THREADS 55 #ifdef SK_USE_POSIX_THREADS
56 pthread_cond_signal(&fCond); 56 pthread_cond_signal(&fCond);
57 #elif defined(SK_BUILD_FOR_WIN32) 57 #elif defined(SK_BUILD_FOR_WIN32)
58 WakeConditionVariable(&fCondition); 58 WakeConditionVariable(&fCondition);
59 #endif 59 #endif
60 } 60 }
61 61
62 void SkCondVar::broadcast() { 62 void CondVar::broadcast() {
63 #ifdef SK_USE_POSIX_THREADS 63 #ifdef SK_USE_POSIX_THREADS
64 pthread_cond_broadcast(&fCond); 64 pthread_cond_broadcast(&fCond);
65 #elif defined(SK_BUILD_FOR_WIN32) 65 #elif defined(SK_BUILD_FOR_WIN32)
66 WakeAllConditionVariable(&fCondition); 66 WakeAllConditionVariable(&fCondition);
67 #endif 67 #endif
68 } 68 }
OLDNEW
« no previous file with comments | « tools/threadpool/CondVar.h ('k') | tools/threadpool/Runnable.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698