if the queue gets destroyed, destroying the awaiters is all we can do.
| 23 | |
| 24 | // if the queue gets destroyed, destroying the awaiters is all we can do. |
| 25 | ~awaitable_spsc_queue() |
| 26 | { |
| 27 | if (auto r = reader.load(); r != nullptr) |
| 28 | std::coroutine_handle<void>::from_address(r).destroy(); |
| 29 | |
| 30 | if (auto w = writer.load(); w != nullptr) |
| 31 | std::coroutine_handle<void>::from_address(w).destroy(); |
| 32 | } |
| 33 | // to avoid locks, put the coroutine handles into atomics. |
| 34 | std::atomic<void*> reader{nullptr}, writer{nullptr}; |
| 35 |