MCPcopy Create free account
hub / github.com/canonical/mir / write_lock

Method write_lock

src/common/thread/recursive_read_write_mutex.cpp:61–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59}
60
61void mir::RecursiveReadWriteMutex::write_lock()
62{
63 auto const my_id = std::this_thread::get_id();
64
65 std::unique_lock lock{mutex};
66 cv.wait(lock, [&]
67 {
68 if (write_locking_thread.count &&
69 write_locking_thread.id != my_id) return false;
70 for (auto const& candidate : read_locking_threads)
71 {
72 if (candidate.id != my_id && candidate.count != 0) return false;
73 }
74 return true;
75 });
76
77 ++write_locking_thread.count;
78 write_locking_thread.id = my_id;
79}
80
81void mir::RecursiveReadWriteMutex::write_unlock()
82{

Callers 2

TEST_FFunction · 0.80
RecursiveWriteLockMethod · 0.80

Calls 1

waitMethod · 0.45

Tested by 1

TEST_FFunction · 0.64