|
|
|
|
|
|
|
|
public:
|
|
|
public:
|
|
|
virtual void resume() = 0;
|
|
|
virtual void resume() = 0;
|
|
|
virtual bool has_handler() const = 0;
|
|
|
virtual bool has_handler() const = 0;
|
|
|
virtual bool switch_scheduler_await_suspend(scheduler_t* sch, coroutine_handle<> handler) = 0;
|
|
|
|
|
|
|
|
|
|
|
|
void set_scheduler(scheduler_t* sch)
|
|
|
void set_scheduler(scheduler_t* sch)
|
|
|
{
|
|
|
{
|
|
|
|
|
|
|
|
|
public:
|
|
|
public:
|
|
|
virtual void resume() override;
|
|
|
virtual void resume() override;
|
|
|
virtual bool has_handler() const override;
|
|
|
virtual bool has_handler() const override;
|
|
|
virtual bool switch_scheduler_await_suspend(scheduler_t* sch, coroutine_handle<> handler) override;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool switch_scheduler_await_suspend(scheduler_t* sch, coroutine_handle<> handler);
|
|
|
|
|
|
|
|
|
void set_initial_suspend(coroutine_handle<> handler)
|
|
|
void set_initial_suspend(coroutine_handle<> handler)
|
|
|
{
|
|
|
{
|
|
|
|
|
|
|
|
|
intptr_t _id;
|
|
|
intptr_t _id;
|
|
|
#endif
|
|
|
#endif
|
|
|
std::exception_ptr _exception;
|
|
|
std::exception_ptr _exception;
|
|
|
uint32_t _alloc_size;
|
|
|
|
|
|
|
|
|
uint32_t _alloc_size = 0;
|
|
|
std::atomic<bool> _has_value{ false };
|
|
|
std::atomic<bool> _has_value{ false };
|
|
|
bool _is_awaitor;
|
|
|
bool _is_awaitor;
|
|
|
initor_type _is_initor = initor_type::None;
|
|
|
initor_type _is_initor = initor_type::None;
|
|
|
|
|
|
|
|
|
virtual void destroy_deallocate() override;
|
|
|
virtual void destroy_deallocate() override;
|
|
|
virtual void resume() override;
|
|
|
virtual void resume() override;
|
|
|
virtual bool has_handler() const override;
|
|
|
virtual bool has_handler() const override;
|
|
|
virtual bool switch_scheduler_await_suspend(scheduler_t* sch, coroutine_handle<> handler) override;
|
|
|
|
|
|
|
|
|
|
|
|
inline bool is_ready() const
|
|
|
inline bool is_ready() const
|
|
|
{
|
|
|
{
|
|
|
|
|
|
|
|
|
set_exception(std::make_exception_ptr(std::move(e)));
|
|
|
set_exception(std::make_exception_ptr(std::move(e)));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
template<class _PromiseT, typename = std::enable_if_t<is_promise_v<_PromiseT>>>
|
|
|
|
|
|
void future_await_suspend(coroutine_handle<_PromiseT> handler);
|
|
|
|
|
|
inline bool future_await_ready()
|
|
|
inline bool future_await_ready()
|
|
|
{
|
|
|
{
|
|
|
//scoped_lock<lock_type> __guard(this->_mtx);
|
|
|
//scoped_lock<lock_type> __guard(this->_mtx);
|
|
|
return _has_value.load(std::memory_order_acquire);
|
|
|
return _has_value.load(std::memory_order_acquire);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
template<class _PromiseT, typename = std::enable_if_t<is_promise_v<_PromiseT>>>
|
|
|
|
|
|
void future_await_suspend(coroutine_handle<_PromiseT> handler);
|
|
|
|
|
|
|
|
|
|
|
|
bool switch_scheduler_await_suspend(scheduler_t* sch, coroutine_handle<> handler);
|
|
|
|
|
|
|
|
|
template<class _PromiseT, typename = std::enable_if_t<is_promise_v<_PromiseT>>>
|
|
|
template<class _PromiseT, typename = std::enable_if_t<is_promise_v<_PromiseT>>>
|
|
|
void promise_initial_suspend(coroutine_handle<_PromiseT> handler);
|
|
|
void promise_initial_suspend(coroutine_handle<_PromiseT> handler);
|
|
|
|
|
|
|
|
|
return static_cast<value_type*>(static_cast<void*>(_value));
|
|
|
return static_cast<value_type*>(static_cast<void*>(_value));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
alignas(value_type) unsigned char _value[sizeof(value_type)];
|
|
|
|
|
|
|
|
|
alignas(value_type) unsigned char _value[sizeof(value_type)] = {0};
|
|
|
};
|
|
|
};
|
|
|
|
|
|
|
|
|
template<>
|
|
|
template<>
|