Skip to content

Commit 6082078

Browse files
authored
🗑️ Remove cancel APIs until we have a suitable implementation (#54)
1 parent b327fcb commit 6082078

File tree

2 files changed

+1
-50
lines changed

2 files changed

+1
-50
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ else()
8888
tests/main.test.cpp
8989
tests/basics.test.cpp
9090
tests/blocked_by.test.cpp
91-
tests/cancel.test.cpp
91+
# tests/cancel.test.cpp
9292
tests/guards.test.cpp
9393
tests/proxy.test.cpp
9494
)

modules/async_context.cppm

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -270,17 +270,6 @@ public:
270270
}
271271
}
272272

273-
/**
274-
* @brief Unsafe cancel will cancel a context's async operation
275-
*
276-
* This operation is labelled as "unsafe" because it this API does not update
277-
* the top level future<T> object that was initially bound to this context,
278-
* to the "cancelled" state. Because of this, using/accessing that future<T>
279-
* in anyway is considered UB.
280-
*
281-
*/
282-
void unsafe_cancel();
283-
284273
[[nodiscard]] constexpr auto memory_used() const noexcept
285274
{
286275
return m_stack_pointer - m_stack.data();
@@ -1029,21 +1018,6 @@ public:
10291018
return *this;
10301019
}
10311020

1032-
void cancel()
1033-
{
1034-
// TODO(#37): consider if cancel should check the context state for blocked
1035-
// by io or external and skip cancellation if thats the case.
1036-
if (std::holds_alternative<handle_type>(m_state)) {
1037-
std::get<handle_type>(m_state).destroy();
1038-
}
1039-
m_state = cancelled_state{};
1040-
}
1041-
1042-
bool is_cancelled()
1043-
{
1044-
return std::holds_alternative<cancelled_state>(m_state);
1045-
}
1046-
10471021
constexpr ~future()
10481022
{
10491023
if (std::holds_alternative<handle_type>(m_state)) {
@@ -1084,27 +1058,4 @@ constexpr future<T> promise<T>::get_return_object() noexcept
10841058
m_context->active_handle(handle);
10851059
return future<T>{ handle };
10861060
}
1087-
1088-
void context::unsafe_cancel()
1089-
{
1090-
// TODO(#38): Consider if a safe variant of cancel is achievable
1091-
if (m_active_handle == std::noop_coroutine()) {
1092-
return;
1093-
}
1094-
1095-
auto index = m_active_handle;
1096-
1097-
while (true) {
1098-
using base_handle = std::coroutine_handle<promise_base>;
1099-
auto top = base_handle::from_address(index.address());
1100-
auto continuation = top.promise().m_continuation;
1101-
if (continuation == std::noop_coroutine()) {
1102-
// We have found our top level coroutine
1103-
top.destroy();
1104-
m_stack_pointer = m_stack.data();
1105-
return;
1106-
}
1107-
index = continuation;
1108-
}
1109-
}
11101061
} // namespace async::inline v0

0 commit comments

Comments
 (0)