-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support variant direct storage and inline operation state
- Loading branch information
1 parent
e6b9f89
commit 97f05b0
Showing
21 changed files
with
2,770 additions
and
780 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// | ||
// Copyright (c) 2021 alandefreitas ([email protected]) | ||
// | ||
// Distributed under the Boost Software License, Version 1.0. | ||
// https://www.boost.org/LICENSE_1_0.txt | ||
// | ||
|
||
#ifndef FUTURES_ADAPTOR_DETAIL_MAKE_READY_FUTURE_HPP | ||
#define FUTURES_ADAPTOR_DETAIL_MAKE_READY_FUTURE_HPP | ||
|
||
#include <futures/futures/basic_future.hpp> | ||
#include <futures/futures/promise.hpp> | ||
#include <futures/futures/traits/is_future.hpp> | ||
#include <future> | ||
|
||
namespace futures::detail { | ||
struct make_ready_future_impl | ||
{ | ||
template <typename T> | ||
basic_future<typename std::decay_t<T>, future_options<>> | ||
make_ready_future(T &&value) { | ||
basic_future<std::decay_t<T>, future_options<>> result( | ||
std::forward<T>(value)); | ||
return result; | ||
} | ||
|
||
template <typename T> | ||
basic_future<T &, future_options<>> | ||
make_ready_future(std::reference_wrapper<T> value) { | ||
promise<T &, future_options<>> p; | ||
basic_future<T &, future_options<>> result = p.get_future(); | ||
p.set_value(value); | ||
return result; | ||
} | ||
|
||
basic_future<void, future_options<>> | ||
make_ready_future() { | ||
promise<void, future_options<>> p; | ||
basic_future<void, future_options<>> result = p.get_future(); | ||
p.set_value(); | ||
return result; | ||
} | ||
|
||
template <typename T = void> | ||
basic_future<T, future_options<>> | ||
make_exceptional_future(std::exception_ptr ex) { | ||
promise<T, future_options<>> p; | ||
p.set_exception(ex); | ||
return p.get_future(); | ||
} | ||
|
||
template <class T = void, class E> | ||
basic_future<T, future_options<>> | ||
make_exceptional_future(E ex) { | ||
promise<T, future_options<>> p; | ||
p.set_exception(std::make_exception_ptr(ex)); | ||
return p.get_future(); | ||
} | ||
}; | ||
} // namespace futures::detail | ||
|
||
#endif // FUTURES_ADAPTOR_DETAIL_MAKE_READY_FUTURE_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.