| 71 | } |
| 72 | |
| 73 | struct Destructo { |
| 74 | bool armed = true; |
| 75 | std::promise<void> p; |
| 76 | |
| 77 | Destructo(std::promise<void>&& p) : p(std::move(p)) {} |
| 78 | Destructo(const Destructo&) = delete; |
| 79 | Destructo& operator =(const Destructo&) = delete; |
| 80 | Destructo(Destructo&& rhs) { |
| 81 | p = std::move(rhs.p); |
| 82 | armed = rhs.armed; |
| 83 | rhs.armed = false; |
| 84 | } |
| 85 | Destructo& operator =(Destructo& rhs) { |
| 86 | p = std::move(rhs.p); |
| 87 | rhs.armed = false; |
| 88 | armed = rhs.armed; |
| 89 | rhs.armed = false; |
| 90 | return *this; |
| 91 | } |
| 92 | |
| 93 | ~Destructo() { |
| 94 | if (armed) |
| 95 | p.set_value(); |
| 96 | } |
| 97 | void operator ()() const { |
| 98 | FAIL(); |
| 99 | } |
| 100 | }; |
| 101 | |
| 102 | template<typename TC> |
| 103 | void cancel_all() |
no outgoing calls