MCPcopy Create free account
hub / github.com/3rdparty/libprocess / read_lock

Method read_lock

include/process/rwlock.hpp:109–124  ·  view source on GitHub ↗

TODO(bmahler): Consider returning a 'Locked' object in the future as the mechanism for unlocking, rather than exposing unlocking functions for all to call.

Source from the content-addressed store, hash-verified

107 // future as the mechanism for unlocking, rather than exposing
108 // unlocking functions for all to call.
109 Future<Nothing> read_lock()
110 {
111 Future<Nothing> future = Nothing();
112
113 synchronized (data->lock) {
114 if (!data->write_locked && data->waiters.empty()) {
115 data->read_locked++;
116 } else {
117 Waiter w{Waiter::READ};
118 future = w.promise.future();
119 data->waiters.push(std::move(w));
120 }
121 }
122
123 return future;
124 }
125
126 void read_unlock()
127 {

Callers 1

TESTFunction · 0.80

Calls 4

futureMethod · 0.80
pushMethod · 0.80
synchronizedFunction · 0.50
emptyMethod · 0.45

Tested by 1

TESTFunction · 0.64