MCPcopy Create free account
hub / github.com/cameron314/concurrentqueue / end_write

Method end_write

benchmarks/tbb/reader_writer_lock.cpp:264–284  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

262}
263
264void reader_writer_lock::end_write(scoped_lock *I) {
265 __TBB_ASSERT(I==writer_head, "Internal error: can't unlock a thread that is not holding the lock.");
266 my_current_writer = tbb_thread::id();
267 ITT_NOTIFY(sync_releasing, this);
268 if (I->next) { // potentially more writers
269 writer_head = I->next;
270 writer_head->status = active;
271 }
272 else { // No more writers; clear writer flag, test reader interest flag
273 __TBB_ASSERT(writer_head, NULL);
274 if (fetch_and_and(rdr_count_and_flags, ~(WFLAG1+WFLAG2)) & RFLAG) {
275 unblock_readers();
276 }
277 writer_head.fetch_and_store(NULL);
278 if (I != writer_tail.compare_and_swap(NULL, I)) { // an incoming writer is in the process of being added
279 spin_wait_while_eq(I->next, (scoped_lock *)NULL); // wait for new writer to be added
280 __TBB_ASSERT(I->next, "There should be a node following the last writer.");
281 set_next_writer(I->next);
282 }
283 }
284}
285
286void reader_writer_lock::end_read() {
287 ITT_NOTIFY(sync_releasing, this);

Callers 1

internal_destroyMethod · 0.80

Calls 5

idClass · 0.85
fetch_and_andFunction · 0.85
spin_wait_while_eqFunction · 0.85
fetch_and_storeMethod · 0.45
compare_and_swapMethod · 0.45

Tested by

no test coverage detected