Cancellation token for request cancellation
| 68 | |
| 69 | // Cancellation token for request cancellation |
| 70 | struct CancellationToken { |
| 71 | std::atomic<bool> is_cancelled; |
| 72 | std::atomic<bool> is_completed; |
| 73 | std::weak_ptr<HttpSession> session; |
| 74 | |
| 75 | CancellationToken(std::shared_ptr<HttpSession> s) : is_cancelled(false), is_completed(false), session(s) {} |
| 76 | |
| 77 | void cancel() { |
| 78 | is_cancelled.store(true); |
| 79 | } |
| 80 | void complete() { |
| 81 | is_completed.store(true); |
| 82 | } |
| 83 | void reset() noexcept { |
| 84 | is_cancelled.store(false, std::memory_order_relaxed); |
| 85 | is_completed.store(false, std::memory_order_relaxed); |
| 86 | } |
| 87 | bool cancelled() const { |
| 88 | return is_cancelled.load(); |
| 89 | } |
| 90 | bool completed() const { |
| 91 | return is_completed.load(); |
| 92 | } |
| 93 | }; |
| 94 | |
| 95 | // Request handler callback type |
| 96 | using RequestHandler = std::function<void( |
nothing calls this directly
no outgoing calls
no test coverage detected