2 * Copyright 2013 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #ifndef SkMutex_win_DEFINED
9 #define SkMutex_win_DEFINED
11 /** Windows CriticalSection based mutex. */
13 #ifndef WIN32_LEAN_AND_MEAN
14 # define WIN32_LEAN_AND_MEAN
15 # define WIN32_IS_MEAN_WAS_LOCALLY_DEFINED
19 # define NOMINMAX_WAS_LOCALLY_DEFINED
24 #ifdef WIN32_IS_MEAN_WAS_LOCALLY_DEFINED
25 # undef WIN32_IS_MEAN_WAS_LOCALLY_DEFINED
26 # undef WIN32_LEAN_AND_MEAN
28 #ifdef NOMINMAX_WAS_LOCALLY_DEFINED
29 # undef NOMINMAX_WAS_LOCALLY_DEFINED
33 // On Windows, SkBaseMutex and SkMutex are the same thing,
34 // we can't easily get rid of static initializers.
38 InitializeCriticalSection(&fStorage);
42 DeleteCriticalSection(&fStorage);
46 EnterCriticalSection(&fStorage);
50 LeaveCriticalSection(&fStorage);
54 SkMutex(const SkMutex&);
55 SkMutex& operator=(const SkMutex&);
57 CRITICAL_SECTION fStorage;
60 typedef SkMutex SkBaseMutex;
62 // Windows currently provides no documented means of POD initializing a CRITICAL_SECTION.
63 #define SK_DECLARE_STATIC_MUTEX(name) static SkBaseMutex name
64 #define SK_DECLARE_GLOBAL_MUTEX(name) SkBaseMutex name