| 369 | } |
| 370 | |
| 371 | inline void inplace_stop_source::__remove_callback_(STDEXEC::__stok::__inplace_stop_callback_base |
| 372 | * __callbk) const noexcept |
| 373 | { |
| 374 | auto __old_state = __lock_(); |
| 375 | |
| 376 | if (__callbk->__prev_ptr_ != nullptr) |
| 377 | { |
| 378 | // Callback has not been executed yet. |
| 379 | // Remove from the list. |
| 380 | *__callbk->__prev_ptr_ = __callbk->__next_; |
| 381 | if (__callbk->__next_ != nullptr) |
| 382 | { |
| 383 | __callbk->__next_->__prev_ptr_ = __callbk->__prev_ptr_; |
| 384 | } |
| 385 | __unlock_(__old_state); |
| 386 | } |
| 387 | else |
| 388 | { |
| 389 | auto __notifying_thread = __notifying_thread_; |
| 390 | __unlock_(__old_state); |
| 391 | |
| 392 | // Callback has either already been executed or is |
| 393 | // currently executing on another thread. |
| 394 | if (std::this_thread::get_id() == __notifying_thread) |
| 395 | { |
| 396 | if (__callbk->__removed_during_callback_ != nullptr) |
| 397 | { |
| 398 | *__callbk->__removed_during_callback_ = true; |
| 399 | } |
| 400 | } |
| 401 | else |
| 402 | { |
| 403 | // Concurrently executing on another thread. |
| 404 | // Wait until the other thread finishes executing the callback. |
| 405 | STDEXEC::__stok::__spin_wait __spin; |
| 406 | while (!__callbk->__callback_completed_.load(STDEXEC::__std::memory_order_acquire)) |
| 407 | { |
| 408 | __spin.__wait(); |
| 409 | } |
| 410 | } |
| 411 | } |
| 412 | } |
| 413 | |
| 414 | struct get_stop_token_t : STDEXEC::__stok::__get_stop_token_t |
| 415 | { |
no test coverage detected