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

Method read_unlock

include/process/rwlock.hpp:126–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

124 }
125
126 void read_unlock()
127 {
128 // NOTE: We need to satisfy the waiter future outside the
129 // critical section because it might trigger callbacks which
130 // try to reacquire a read or write lock.
131 Option<Waiter> waiter;
132
133 synchronized (data->lock) {
134 CHECK(!data->write_locked);
135 CHECK_GT(data->read_locked, 0u);
136
137 data->read_locked--;
138
139 if (data->read_locked == 0u && !data->waiters.empty()) {
140 CHECK_EQ(data->waiters.front().type, Waiter::WRITE);
141
142 waiter = std::move(data->waiters.front());
143 data->waiters.pop();
144 data->write_locked = true;
145 }
146 }
147
148 if (waiter.isSome()) {
149 waiter->promise.set(Nothing());
150 }
151 }
152
153private:
154 struct Waiter

Callers 1

TESTFunction · 0.80

Calls 3

synchronizedFunction · 0.50
emptyMethod · 0.45
setMethod · 0.45

Tested by 1

TESTFunction · 0.64