MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / tryAcquireWrite

Method tryAcquireWrite

src/readwritelock.h:61–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59 }
60
61 bool tryAcquireWrite(bool exclusive = true) {
62 std::unique_lock<fastlock> rm(m_readLock, std::defer_lock);
63 if (m_multi) {
64 if (!rm.try_lock())
65 return false;
66 if (m_readCount > 0)
67 return false;
68 if (exclusive)
69 if (!m_writeLock.try_lock())
70 return false;
71 }
72 m_writeCount++;
73 return true;
74 }
75
76 void releaseRead() {
77 std::unique_lock<fastlock> rm(m_readLock, std::defer_lock);

Callers 1

moduleTryAcquireGILFunction · 0.80

Calls 1

try_lockMethod · 0.45

Tested by

no test coverage detected