MCPcopy Create free account
hub / github.com/Snapchat/Valdi / TrackedLock

Class TrackedLock

valdi_core/src/valdi_core/cpp/Utils/TrackedLock.hpp:13–38  ·  view source on GitHub ↗

A lock implementation for Valdi::RecursiveMutex which uses a thread local storage to track all the locks acquired so that it can unlock them. */

Source from the content-addressed store, hash-verified

11/**
12A lock implementation for Valdi::RecursiveMutex which uses a thread local storage
13to track all the locks acquired so that it can unlock them.
14 */
15class TrackedLock {
16public:
17 TrackedLock();
18 TrackedLock(RecursiveMutex& mutex);
19 /**
20 Try to acquire the mutex until the deadline, polling instead of blocking, so the calling
21 thread can never park on the mutex indefinitely. A deadline in the past attempts exactly
22 once. Check owns() for the outcome.
23 */
24 TrackedLock(RecursiveMutex& mutex, const std::chrono::steady_clock::time_point& deadline);
25 TrackedLock(TrackedLock&& other) noexcept;
26
27 ~TrackedLock();
28
29 void lock();
30 void unlock();
31
32 bool owns() const;
33
34 TrackedLock& operator=(TrackedLock&& other) noexcept;
35
36private:
37 friend DropAllTrackedLocks;
38
39 TrackedLock* _parent = nullptr;
40 RecursiveMutex* _mutex = nullptr;
41 bool _owns = false;

Callers 3

TrackedLock.cppFile · 0.85
resolveViewNodeTreeMethod · 0.85
lockMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected