MCPcopy Create free account
hub / github.com/deepseek-ai/3FS / writeLock

Method writeLock

src/common/utils/ReentrantLockManager.cc:105–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103}
104
105ReentrantLockManager::LockGuard ReentrantLockManager::writeLock(uint64_t id) {
106 auto guard = folly::makeGuard(
107 [now = std::chrono::steady_clock::now()] { writeLockLatency.addSample(std::chrono::steady_clock::now() - now); });
108
109 auto &shard = getShard(id);
110 auto lock = std::unique_lock(shard.mutex);
111 auto &status = shard.map[id];
112
113 if (!status.readyToWriteLock()) {
114 auto start = std::chrono::steady_clock::now();
115 ++status.waitingWriteLock;
116 shard.writeCond.wait(lock, [&] { return shard.map[id].readyToWriteLock(); });
117 --status.waitingWriteLock;
118 auto elapsed = std::chrono::steady_clock::now() - start;
119 writeLockWaitingLatency.addSample(elapsed);
120 }
121 status.writeLock();
122 return LockGuard(this, id, LockType::WRITE);
123}
124
125ReentrantLockManager::LockGuard ReentrantLockManager::tryWriteLock(uint64_t id) {
126 auto &shard = getShard(id);

Callers 2

tryWriteLockMethod · 0.45
TESTFunction · 0.45

Calls 4

LockGuardClass · 0.85
readyToWriteLockMethod · 0.80
addSampleMethod · 0.45
waitMethod · 0.45

Tested by 1

TESTFunction · 0.36