MCPcopy Create free account
hub / github.com/NVIDIA/stdexec / __try_lock_unless_stop_requested_

Method __try_lock_unless_stop_requested_

include/stdexec/stop_token.hpp:314–348  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

312 }
313
314 inline auto inplace_stop_source::__try_lock_unless_stop_requested_(bool __set_stop_requested)
315 const noexcept -> bool
316 {
317 STDEXEC::__stok::__spin_wait __spin;
318 auto __old_state = __state_.load(STDEXEC::__std::memory_order_relaxed);
319 do
320 {
321 while (true)
322 {
323 if ((__old_state & __stop_requested_flag_) != 0)
324 {
325 // Stop already requested.
326 return false;
327 }
328 else if (__old_state == 0)
329 {
330 break;
331 }
332 else
333 {
334 __spin.__wait();
335 __old_state = __state_.load(STDEXEC::__std::memory_order_relaxed);
336 }
337 }
338 }
339 while (!__state_.compare_exchange_weak(__old_state,
340 __set_stop_requested
341 ? (__locked_flag_ | __stop_requested_flag_)
342 : __locked_flag_,
343 STDEXEC::__std::memory_order_acq_rel,
344 STDEXEC::__std::memory_order_relaxed));
345
346 // Lock acquired successfully
347 return true;
348 }
349
350 inline auto inplace_stop_source::__try_add_callback_(STDEXEC::__stok::__inplace_stop_callback_base
351 * __callbk) const noexcept -> bool

Callers

nothing calls this directly

Calls 3

__waitMethod · 0.80
compare_exchange_weakMethod · 0.80
loadMethod · 0.45

Tested by

no test coverage detected