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

Side by Side Diff: include/core/SkMutex.h

Issue 896553002: Atomics overhaul. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: warning Created 5 years, 10 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 | « include/core/SkBarriers.h ('k') | include/core/SkThread.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 #ifndef SkMutex_DEFINED 1 #ifndef SkMutex_DEFINED
2 #define SkMutex_DEFINED 2 #define SkMutex_DEFINED
3 3
4 // This file is not part of the public Skia API. 4 // This file is not part of the public Skia API.
5 #include "SkTypes.h" 5 #include "SkTypes.h"
6 6
7 #if defined(SK_BUILD_FOR_WIN) 7 #if defined(SK_BUILD_FOR_WIN)
8 #include "../ports/SkMutex_win.h" 8 #include "../ports/SkMutex_win.h"
9 #else 9 #else
10 #include "../ports/SkMutex_pthread.h" 10 #include "../ports/SkMutex_pthread.h"
11 #endif 11 #endif
12 12
13 class SkAutoMutexAcquire : SkNoncopyable {
14 public:
15 explicit SkAutoMutexAcquire(SkBaseMutex& mutex) : fMutex(&mutex) {
16 SkASSERT(fMutex != NULL);
17 mutex.acquire();
18 }
19
20 explicit SkAutoMutexAcquire(SkBaseMutex* mutex) : fMutex(mutex) {
21 if (mutex) {
22 mutex->acquire();
23 }
24 }
25
26 /** If the mutex has not been released, release it now. */
27 ~SkAutoMutexAcquire() {
28 if (fMutex) {
29 fMutex->release();
30 }
31 }
32
33 /** If the mutex has not been released, release it now. */
34 void release() {
35 if (fMutex) {
36 fMutex->release();
37 fMutex = NULL;
38 }
39 }
40
41 /** Assert that we're holding the mutex. */
42 void assertHeld() {
43 SkASSERT(fMutex);
44 fMutex->assertHeld();
45 }
46
47 private:
48 SkBaseMutex* fMutex;
49 };
50 #define SkAutoMutexAcquire(...) SK_REQUIRE_LOCAL_VAR(SkAutoMutexAcquire)
51
52
13 #endif//SkMutex_DEFINED 53 #endif//SkMutex_DEFINED
OLDNEW
« no previous file with comments | « include/core/SkBarriers.h ('k') | include/core/SkThread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698