3 #include "Impl/AsyncSystemSchedulers.h"
4 #include "Impl/cesium-async++.h"
11 template <
typename T>
class Future;
25 void resolve(T&& value)
const { this->_pEvent->set(std::move(value)); }
32 void resolve(
const T& value)
const { this->_pEvent->set(value); }
39 template <
typename TException>
void reject(TException error)
const {
40 this->_pEvent->set_exception(std::make_exception_ptr(error));
49 void reject(
const std::exception_ptr& error)
const {
50 this->_pEvent->set_exception(error);
62 return Future<T>(this->_pSchedulers, this->_pEvent->get_task());
67 const std::shared_ptr<CesiumImpl::AsyncSystemSchedulers>& pSchedulers,
68 const std::shared_ptr<async::event_task<T>>& pEvent) noexcept
69 : _pSchedulers(pSchedulers), _pEvent(pEvent) {}
71 std::shared_ptr<CesiumImpl::AsyncSystemSchedulers> _pSchedulers;
72 std::shared_ptr<async::event_task<T>> _pEvent;
74 friend class AsyncSystem;
80 void resolve()
const { this->_pEvent->set(); }
81 template <
typename TException>
void reject(TException error)
const {
82 this->_pEvent->set_exception(std::make_exception_ptr(error));
84 void reject(
const std::exception_ptr& error)
const {
85 this->_pEvent->set_exception(error);
88 return Future<void>(this->_pSchedulers, this->_pEvent->get_task());
93 const std::shared_ptr<CesiumImpl::AsyncSystemSchedulers>& pSchedulers,
94 const std::shared_ptr<async::event_task<void>>& pEvent) noexcept
95 : _pSchedulers(pSchedulers), _pEvent(pEvent) {}
97 std::shared_ptr<CesiumImpl::AsyncSystemSchedulers> _pSchedulers;
98 std::shared_ptr<async::event_task<void>> _pEvent;
A system for managing asynchronous requests and tasks.
A value that will be available in the future, as produced by AsyncSystem.
A promise that can be resolved or rejected by an asynchronous task.
Future< T > getFuture() const
Gets the Future that resolves or rejects when this Promise is resolved or rejected.
void resolve(const T &value) const
Will be called when the task completed successfully.
void reject(const std::exception_ptr &error) const
Will be called when the task failed.
void resolve(T &&value) const
Will be called when the task completed successfully.
void reject(TException error) const
Will be called when the task failed.
Classes that support asynchronous operations.