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

Go to the source code of this file.

Classes

class  SkAutoMutexExclusive
 

Functions

class SK_CAPABILITY ("mutex") SkMutex
 

Function Documentation

◆ SK_CAPABILITY()

class SK_CAPABILITY ( "mutex"  )

Definition at line 1 of file SkMutex.h.

17 {
18public:
19 constexpr SkMutex() = default;
20
21 ~SkMutex() {
22 this->assertNotHeld();
23 }
24
25 void acquire() SK_ACQUIRE() {
26 fSemaphore.wait();
27 SkDEBUGCODE(fOwner = SkGetThreadID();)
28 }
29
30 void release() SK_RELEASE_CAPABILITY() {
31 this->assertHeld();
33 fSemaphore.signal();
34 }
35
36 void assertHeld() SK_ASSERT_CAPABILITY(this) {
37 SkASSERT(fOwner == SkGetThreadID());
38 }
39
40 void assertNotHeld() {
41 SkASSERT(fOwner == kIllegalThreadID);
42 }
43
44private:
45 SkSemaphore fSemaphore{1};
47};
#define SkASSERT(cond)
Definition: SkAssert.h:116
#define SK_RELEASE_CAPABILITY(...)
#define SK_ACQUIRE(...)
#define SK_ASSERT_CAPABILITY(x)
SkThreadID SkGetThreadID()
Definition: SkThreadID.cpp:15
const SkThreadID kIllegalThreadID
Definition: SkThreadID.h:21
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()
int64_t SkThreadID
Definition: SkThreadID.h:16