Skip to content

Commit

Permalink
No need for an exception container.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnbrq committed Oct 1, 2023
1 parent b877bd6 commit debea51
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 51 deletions.
3 changes: 0 additions & 3 deletions include/cxxdes/core/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ struct immediately_return;
struct interrupted_exception;
struct stopped_exception;

struct exception_container;

struct coroutine_data;
using coroutine_data_ptr = memory::ptr<coroutine_data>;
using const_coroutine_data_ptr = memory::ptr<const coroutine_data>;
Expand All @@ -85,7 +83,6 @@ struct subroutine;
#include "impl/token.ipp"
#include "impl/immediately_return.ipp"
#include "impl/exception_types.ipp"
#include "impl/exception_container.ipp"
#include "impl/coroutine_data.ipp"
#include "impl/environment.ipp"
#include "impl/timeout.ipp"
Expand Down
13 changes: 8 additions & 5 deletions include/cxxdes/core/impl/coroutine_data.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ struct coroutine_data: memory::reference_counted_base<coroutine_data> {

template <typename T = interrupted_exception>
void interrupt(T &&t = interrupted_exception{}) noexcept {
exception_.assign(std::forward<T>(t));
exception_ = std::make_exception_ptr(std::forward<T>(t));
}

[[nodiscard]]
bool interrupted() const noexcept {
return exception_.valid();
return (bool) exception_;
}

[[nodiscard]]
Expand Down Expand Up @@ -118,10 +118,13 @@ protected:
void unmanage_();

void raise_interrupt_() {
std::exception_ptr exception = exception_;

// clear exception_, the exception might be caught
// we may need to interrupt again later
auto exception = std::move(exception_);
exception.raise();
exception_ = nullptr;

std::rethrow_exception(exception);
}

void push_coro_(coroutine_handle coro) {
Expand Down Expand Up @@ -157,7 +160,7 @@ protected:
time_integral latency_ = 0;
memory::ptr<coroutine_data> parent_;
bool complete_ = false;
exception_container exception_;
std::exception_ptr exception_;
};


Expand Down
43 changes: 0 additions & 43 deletions include/cxxdes/core/impl/exception_container.ipp

This file was deleted.

0 comments on commit debea51

Please sign in to comment.