OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2013 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 SkMutex_win_DEFINED |
| 9 #define SkMutex_win_DEFINED |
| 10 |
| 11 /** Windows CriticalSection based mutex. */ |
| 12 |
| 13 #include "SkTypes.h" |
| 14 |
| 15 // On Windows, SkBaseMutex and SkMutex are the same thing, |
| 16 // we can't easily get rid of static initializers. |
| 17 class SkMutex : SkNoncopyable { |
| 18 public: |
| 19 SkMutex() { |
| 20 InitializeCriticalSection(&fStorage); |
| 21 } |
| 22 |
| 23 ~SkMutex() { |
| 24 DeleteCriticalSection(&fStorage); |
| 25 } |
| 26 |
| 27 void acquire() { |
| 28 EnterCriticalSection(&fStorage); |
| 29 } |
| 30 |
| 31 void release() { |
| 32 LeaveCriticalSection(&fStorage); |
| 33 } |
| 34 |
| 35 private: |
| 36 CRITICAL_SECTION fStorage; |
| 37 }; |
| 38 |
| 39 typedef SkMutex SkBaseMutex; |
| 40 |
| 41 // Windows currently provides no documented means of POD initializing a CRITICAL
_SECTION. |
| 42 #define SK_DECLARE_STATIC_MUTEX(name) static SkBaseMutex name |
| 43 #define SK_DECLARE_GLOBAL_MUTEX(name) SkBaseMutex name |
| 44 |
| 45 #endif |
OLD | NEW |