MCPcopy Create free account
hub / github.com/David-Haim/concurrencpp / unlock

Method unlock

source/threads/async_lock.cpp:121–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

119}
120
121void async_lock::unlock() {
122 std::unique_lock<std::mutex> lock(m_awaiter_lock);
123 if (!m_locked) { // trying to unlocked non-owned mutex
124 lock.unlock();
125 throw std::system_error(static_cast<int>(std::errc::operation_not_permitted),
126 std::system_category(),
127 details::consts::k_async_lock_unlock_invalid_lock_err_msg);
128 }
129
130 m_locked = false;
131
132#ifdef CRCPP_DEBUG_MODE
133 const auto current_count = m_thread_count_in_critical_section.fetch_sub(1, std::memory_order_relaxed);
134 assert(current_count == 1);
135#endif
136
137 const auto awaiter = m_awaiters.pop_front();
138 lock.unlock();
139
140 if (awaiter != nullptr) {
141 awaiter->retry();
142 }
143}
144
145/*
146 * scoped_async_lock

Callers 15

enqueueMethod · 0.80
loop_implMethod · 0.80
loop_until_implMethod · 0.80
clearMethod · 0.80
retire_workerMethod · 0.80
wait_for_taskMethod · 0.80
drain_queueMethod · 0.80
enqueue_foreignMethod · 0.80
wait_for_taskMethod · 0.80
drain_queueMethod · 0.80
ensure_worker_activeMethod · 0.80
lock_implMethod · 0.80

Calls 2

pop_frontMethod · 0.80
retryMethod · 0.80