Flutter Engine
The Flutter Engine
Classes | Functions
SkSharedMutex.h File Reference
#include "include/private/base/SkDebug.h"
#include "include/private/base/SkSemaphore.h"
#include "include/private/base/SkThreadAnnotations.h"

Go to the source code of this file.

Classes

class  SkAutoSharedMutexExclusive
 
class  SkAutoSharedMutexShared
 

Functions

class SK_CAPABILITY ("mutex") SkSharedMutex
 

Function Documentation

◆ SK_CAPABILITY()

class SK_CAPABILITY ( "mutex"  )

Definition at line 1 of file SkSharedMutex.h.

28 {
29public:
30 SkSharedMutex();
31 ~SkSharedMutex();
32 // Acquire lock for exclusive use.
33 void acquire() SK_ACQUIRE();
34
35 // Release lock for exclusive use.
36 void release() SK_RELEASE_CAPABILITY();
37
38 // Fail if exclusive is not held.
39 void assertHeld() const SK_ASSERT_CAPABILITY(this);
40
41 // Acquire lock for shared use.
42 void acquireShared() SK_ACQUIRE_SHARED();
43
44 // Release lock for shared use.
45 void releaseShared() SK_RELEASE_SHARED_CAPABILITY();
46
47 // Fail if shared lock not held.
48 void assertHeldShared() const SK_ASSERT_SHARED_CAPABILITY(this);
49
50private:
51#ifdef SK_DEBUG
52 class ThreadIDSet;
53 std::unique_ptr<ThreadIDSet> fCurrentShared;
54 std::unique_ptr<ThreadIDSet> fWaitingExclusive;
55 std::unique_ptr<ThreadIDSet> fWaitingShared;
56 int fSharedQueueSelect{0};
57 mutable SkMutex fMu;
58 SkSemaphore fSharedQueue[2];
59 SkSemaphore fExclusiveQueue;
60#else
61 std::atomic<int32_t> fQueueCounts;
62 SkSemaphore fSharedQueue;
63 SkSemaphore fExclusiveQueue;
64#endif // SK_DEBUG
65};
#define SK_RELEASE_CAPABILITY(...)
#define SK_ASSERT_SHARED_CAPABILITY(x)
#define SK_RELEASE_SHARED_CAPABILITY(...)
#define SK_ACQUIRE(...)
#define SK_ACQUIRE_SHARED(...)
#define SK_ASSERT_CAPABILITY(x)