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

Side by Side Diff: src/utils/SkCondVar.h

Issue 1192573003: Add and use SkSemaphore (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: typo Created 5 years, 6 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 | « src/core/SkTaskGroup.cpp ('k') | src/utils/SkCondVar.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2012 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef SkCondVar_DEFINED
9 #define SkCondVar_DEFINED
10
11 #include "SkTypes.h"
12
13 #ifdef SK_BUILD_FOR_WIN32
14 #include <windows.h>
15 #else
16 #include <pthread.h>
17 #endif
18
19 /**
20 * Condition variable for blocking access to shared data from other threads and
21 * controlling which threads are awake.
22 *
23 * Currently only supported on platforms with posix threads and Windows Vista an d above.
24 */
25 class SkCondVar {
26 public:
27 /** Returns true if it makes sense to create and use SkCondVars.
28 * You _MUST_ call this method and it must return true before creating any SkCondVars.
29 */
30 static bool Supported();
31
32 SkCondVar();
33 ~SkCondVar();
34
35 /**
36 * Lock a mutex. Must be done before calling the other functions on this obj ect.
37 */
38 void lock();
39
40 /**
41 * Unlock the mutex.
42 */
43 void unlock();
44
45 /**
46 * Pause the calling thread. Will be awoken when signal() or broadcast() is called.
47 * Must be called while lock() is held (but gives it up while waiting). Once awoken,
48 * the calling thread will hold the lock once again.
49 */
50 void wait();
51
52 /**
53 * Wake one thread waiting on this condition. Must be called while lock()
54 * is held.
55 */
56 void signal();
57
58 /**
59 * Wake all threads waiting on this condition. Must be called while lock()
60 * is held.
61 */
62 void broadcast();
63
64 private:
65 #ifdef SK_BUILD_FOR_WIN32
66 CRITICAL_SECTION fCriticalSection;
67 CONDITION_VARIABLE fCondition;
68 #else
69 pthread_mutex_t fMutex;
70 pthread_cond_t fCond;
71 #endif
72 };
73
74 #endif
OLDNEW
« no previous file with comments | « src/core/SkTaskGroup.cpp ('k') | src/utils/SkCondVar.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698