| 275 | std::shared_ptr<concurrencpp::timer_queue> self, |
| 276 | std::shared_ptr<concurrencpp::executor> executor) { |
| 277 | class delay_object_awaitable : public details::suspend_always { |
| 278 | |
| 279 | private: |
| 280 | const size_t m_due_time_ms; |
| 281 | timer_queue& m_parent_queue; |
| 282 | std::shared_ptr<concurrencpp::executor> m_executor; |
| 283 | bool m_interrupted = false; |
| 284 | |
| 285 | public: |
| 286 | delay_object_awaitable(size_t due_time_ms, |
| 287 | timer_queue& parent_queue, |
| 288 | std::shared_ptr<concurrencpp::executor> executor) noexcept : |
| 289 | m_due_time_ms(due_time_ms), |
| 290 | m_parent_queue(parent_queue), m_executor(std::move(executor)) {} |
| 291 | |
| 292 | void await_suspend(details::coroutine_handle<void> coro_handle) noexcept { |
| 293 | try { |
| 294 | m_parent_queue.make_timer_impl(m_due_time_ms, |
| 295 | 0, |
| 296 | std::move(m_executor), |
| 297 | true, |
| 298 | details::await_via_functor {coro_handle, &m_interrupted}); |
| 299 | |
| 300 | } catch (...) { |
| 301 | // do nothing. ~await_via_functor will resume the coroutine and throw an exception. |
| 302 | } |
| 303 | } |
| 304 | |
| 305 | void await_resume() const { |
| 306 | if (m_interrupted) { |
| 307 | throw errors::broken_task(details::consts::k_broken_task_exception_error_msg); |
| 308 | } |
| 309 | } |
| 310 | }; |
| 311 | |
| 312 | co_await delay_object_awaitable {static_cast<size_t>(due_time.count()), *this, std::move(executor)}; |
| 313 | } |
nothing calls this directly
no outgoing calls
no test coverage detected