\brief Submits the given task to the io_uring. \returns true if the task was submitted, false if this io context and this task is have been stopped.
| 468 | /// \brief Submits the given task to the io_uring. |
| 469 | /// \returns true if the task was submitted, false if this io context and this task is have been stopped. |
| 470 | auto submit(__task* __op) noexcept -> bool |
| 471 | { |
| 472 | // As long as the number of in-flight submissions is not __no_new_submissions, we can |
| 473 | // increment the counter and push the operation onto the queue. |
| 474 | // If the number of in-flight submissions is __no_new_submissions, we have already |
| 475 | // finished the stop operation of the io context and we can immediately stop the operation inline. |
| 476 | // Remark: As long as the stopping is in progress we can still submit new operations. |
| 477 | // But no operation will be submitted to io uring unless it is a cancellation operation. |
| 478 | int __n = 0; |
| 479 | while (__n != __no_new_submissions |
| 480 | && !__n_submissions_in_flight_.compare_exchange_weak( |
| 481 | __n, |
| 482 | __n + 1, |
| 483 | STDEXEC::__std::memory_order_acquire, |
| 484 | STDEXEC::__std::memory_order_relaxed)) |
| 485 | ; |
| 486 | if (__n == __no_new_submissions) |
| 487 | { |
| 488 | __stop(__op); |
| 489 | return false; |
| 490 | } |
| 491 | else |
| 492 | { |
| 493 | __requests_.push_front(__op); |
| 494 | [[maybe_unused]] |
| 495 | int __prev = __n_submissions_in_flight_.fetch_sub(1, |
| 496 | STDEXEC::__std::memory_order_relaxed); |
| 497 | STDEXEC_ASSERT(__prev > 0); |
| 498 | return true; |
| 499 | } |
| 500 | } |
| 501 | |
| 502 | /// @brief Submit any pending tasks and complete any ready tasks. |
| 503 | /// |
no test coverage detected