MCPcopy Create free account
hub / github.com/bshoshany/thread-pool / try_acquire_for

Method try_acquire_for

tests/BS_thread_pool_test.cpp:204–215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

202 */
203 template <class Rep, class Period>
204 bool try_acquire_for(const std::chrono::duration<Rep, Period>& rel_time)
205 {
206 std::unique_lock lock(mutex);
207 if (!cv.wait_for(lock, rel_time,
208 [this]
209 {
210 return counter > 0;
211 }))
212 return false;
213 --counter;
214 return true;
215 }
216
217 /**
218 * @brief Tries to atomically decrement the internal counter by 1 if it is greater than 0; otherwise blocks until it is greater than 0 and can successfully decrement the internal counter, or the `abs_time` time point has been passed.

Callers

nothing calls this directly

Calls 1

wait_forMethod · 0.80

Tested by

no test coverage detected