MCPcopy Create free account
hub / github.com/Tencent/MMKV / InterProcessLock

Class InterProcessLock

Core/InterProcessLock.h:90–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88};
89
90class InterProcessLock {
91 FileLock *m_fileLock;
92 LockType m_lockType;
93
94public:
95 InterProcessLock(FileLock *fileLock, LockType lockType)
96 : m_fileLock(fileLock), m_lockType(lockType), m_enable(true) {
97 MMKV_ASSERT(m_fileLock);
98 }
99
100 bool m_enable;
101
102 void lock() {
103 if (m_enable) {
104 m_fileLock->lock(m_lockType);
105 }
106 }
107
108 bool try_lock(bool *tryAgain = nullptr) {
109 if (m_enable) {
110 return m_fileLock->try_lock(m_lockType, tryAgain);
111 }
112 return false;
113 }
114
115 void unlock() {
116 if (m_enable) {
117 m_fileLock->unlock(m_lockType);
118 }
119 }
120};
121
122} // namespace mmkv
123

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected