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

Side by Side Diff: src/core/SkSharedMutex.h

Issue 1213663004: Add annotations to SkSharedMutex. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: whitespace cleanup Created 5 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 | « no previous file | src/core/SkSharedMutex.cpp » ('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 2015 Google Inc. 2 * Copyright 2015 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 #ifndef SkSharedLock_DEFINED 8 #ifndef SkSharedLock_DEFINED
9 #define SkSharedLock_DEFINED 9 #define SkSharedLock_DEFINED
10 10
11 #include "SkAtomics.h" 11 #include "SkAtomics.h"
12 #include "SkSemaphore.h" 12 #include "SkSemaphore.h"
13 #include "SkTypes.h" 13 #include "SkTypes.h"
14 14
15 // This is a shared lock implementation similar to pthreads rwlocks. This implem entation is 15 // This is a shared lock implementation similar to pthreads rwlocks. This implem entation is
16 // cribbed from Preshing's article: 16 // cribbed from Preshing's article:
17 // http://preshing.com/20150316/semaphores-are-surprisingly-versatile/ 17 // http://preshing.com/20150316/semaphores-are-surprisingly-versatile/
18 // 18 //
19 // This lock does not obey strict queue ordering. It will always alternate betwe en readers and 19 // This lock does not obey strict queue ordering. It will always alternate betwe en readers and
20 // a single writer. 20 // a single writer.
21 class SkSharedMutex { 21 class SkSharedMutex {
22 public: 22 public:
23 SkSharedMutex(); 23 SkSharedMutex();
24 24 ~SkSharedMutex();
25 // Acquire lock for exclusive use. 25 // Acquire lock for exclusive use.
26 void acquire(); 26 void acquire();
27 27
28 // Release lock for exclusive use. 28 // Release lock for exclusive use.
29 void release(); 29 void release();
30 30
31 // Acquire lock for shared use. 31 // Acquire lock for shared use.
32 void acquireShared(); 32 void acquireShared();
33 33
34 // Release lock for shared use. 34 // Release lock for shared use.
35 void releaseShared(); 35 void releaseShared();
36 36
37 private: 37 private:
38 SkAtomic<int32_t> fQueueCounts; 38 SkAtomic<int32_t> fQueueCounts;
39 SkSemaphore fSharedQueue; 39 SkSemaphore fSharedQueue;
40 SkSemaphore fExclusiveQueue; 40 SkSemaphore fExclusiveQueue;
41 }; 41 };
42 42
43 #endif // SkSharedLock_DEFINED 43 #endif // SkSharedLock_DEFINED
OLDNEW
« no previous file with comments | « no previous file | src/core/SkSharedMutex.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698