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

Method platformUnLock

Core/InterProcessLock_Win32.cpp:82–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80}
81
82bool FileLock::platformUnLock(bool unlockToSharedLock) {
83 /* quote from MSDN:
84 * If the same range is locked with an exclusive and a shared lock,
85 * two unlock operations are necessary to unlock the region;
86 * the first unlock operation unlocks the exclusive lock,
87 * the second unlock operation unlocks the shared lock.
88 */
89 if (unlockToSharedLock) {
90 auto flag = LockType2Flag(SharedLockType);
91 if (!LockFileEx(m_fd, flag, 0, 1, 0, &m_overLapped)) {
92 MMKVError("fail to roll back to shared-lock, error:%d", GetLastError());
93 }
94 }
95 auto ret = UnlockFileEx(m_fd, 0, 1, 0, &m_overLapped);
96 if (!ret) {
97 auto lastError = GetLastError();
98 if (lastError != ERROR_NOT_LOCKED) {
99 MMKVError("fail to unlock fd=%p, error:%d", m_fd, lastError);
100 return false;
101 }
102 }
103 return true;
104}
105
106} // namespace mmkv
107

Callers

nothing calls this directly

Calls 1

LockType2FlagFunction · 0.85

Tested by

no test coverage detected