mirror of
https://github.com/Naios/continuable.git
synced 2026-02-14 06:09:48 +08:00
Make continuable.hpp include all headers of the library
* Move the old continuable.hpp header into continuable-types.hpp
This commit is contained in:
parent
7aae524cb1
commit
f4ee3ea0d1
109
include/continuable/continuable-types.hpp
Normal file
109
include/continuable/continuable-types.hpp
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
/~` _ _ _|_. _ _ |_ | _
|
||||||
|
\_,(_)| | | || ||_|(_||_)|(/_
|
||||||
|
|
||||||
|
https://github.com/Naios/continuable
|
||||||
|
v2.0.0
|
||||||
|
|
||||||
|
Copyright(c) 2015 - 2018 Denis Blank <denis.blank at outlook dot com>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files(the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions :
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
**/
|
||||||
|
|
||||||
|
#ifndef CONTINUABLE_TYPES_HPP_INCLUDED__
|
||||||
|
#define CONTINUABLE_TYPES_HPP_INCLUDED__
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
#include <function2/function2.hpp>
|
||||||
|
|
||||||
|
#include <continuable/continuable-api.hpp>
|
||||||
|
#include <continuable/continuable-trait.hpp>
|
||||||
|
|
||||||
|
namespace cti {
|
||||||
|
// clang-format off
|
||||||
|
namespace detail {
|
||||||
|
/// A function which isn't size adjusted and copyable
|
||||||
|
template<std::size_t Size, typename... Args>
|
||||||
|
using function_adapter = fu2::function<Args...>;
|
||||||
|
/// A function which isn't size adjusted and move only
|
||||||
|
template<std::size_t, typename... Args>
|
||||||
|
using unique_function_adapter = fu2::unique_function<Args...>;
|
||||||
|
/// A function which is size adjusted and copyable
|
||||||
|
template<std::size_t Size, typename... Args>
|
||||||
|
using function_adjustable = fu2::function_base<true, true, Size,
|
||||||
|
true, false, Args...>;
|
||||||
|
/// A function which is size adjusted and move only
|
||||||
|
template<std::size_t Size, typename... Args>
|
||||||
|
using unique_function_adjustable = fu2::function_base<true, false, Size,
|
||||||
|
true, false, Args...>;
|
||||||
|
|
||||||
|
/// We adjust the internal capacity of the outer function wrapper so
|
||||||
|
/// we don't have to allocate twice when using `continuable<...>`.
|
||||||
|
template<typename... Args>
|
||||||
|
using trait_of = continuable_trait<
|
||||||
|
unique_function_adapter,
|
||||||
|
function_adjustable,
|
||||||
|
Args...
|
||||||
|
>;
|
||||||
|
|
||||||
|
template<typename... Args>
|
||||||
|
using unique_trait_of = continuable_trait<
|
||||||
|
unique_function_adapter,
|
||||||
|
unique_function_adjustable,
|
||||||
|
Args...
|
||||||
|
>;
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
|
/// Defines a copyable continuation type which uses the
|
||||||
|
/// function2 backend for type erasure.
|
||||||
|
///
|
||||||
|
/// Usable like: `cti::continuable<int, float>`
|
||||||
|
template <typename... Args>
|
||||||
|
using continuable = typename detail::trait_of<
|
||||||
|
Args...
|
||||||
|
>::continuable;
|
||||||
|
|
||||||
|
/// Defines a non-copyable continuation type which uses the
|
||||||
|
/// function2 backend for type erasure.
|
||||||
|
///
|
||||||
|
/// Usable like: `unique_continuable<int, float>`
|
||||||
|
template <typename... Args>
|
||||||
|
using unique_continuable = typename detail::unique_trait_of<
|
||||||
|
Args...
|
||||||
|
>::continuable;
|
||||||
|
|
||||||
|
/// Defines a non-copyable promise type which is using the
|
||||||
|
/// function2 backend for type erasure.
|
||||||
|
///
|
||||||
|
/// Usable like: `promise<int, float>`
|
||||||
|
template <typename... Args>
|
||||||
|
using promise = typename detail::unique_trait_of<
|
||||||
|
Args...
|
||||||
|
>::promise;
|
||||||
|
|
||||||
|
// TODO channel
|
||||||
|
// TODO sink
|
||||||
|
|
||||||
|
// clang-format on
|
||||||
|
} // namespace cti
|
||||||
|
|
||||||
|
#endif // CONTINUABLE_TYPES_HPP_INCLUDED__
|
||||||
@ -31,79 +31,12 @@
|
|||||||
#ifndef CONTINUABLE_HPP_INCLUDED__
|
#ifndef CONTINUABLE_HPP_INCLUDED__
|
||||||
#define CONTINUABLE_HPP_INCLUDED__
|
#define CONTINUABLE_HPP_INCLUDED__
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
#include <function2/function2.hpp>
|
|
||||||
|
|
||||||
#include <continuable/continuable-api.hpp>
|
#include <continuable/continuable-api.hpp>
|
||||||
|
#include <continuable/continuable-base.hpp>
|
||||||
|
#include <continuable/continuable-promise-base.hpp>
|
||||||
|
#include <continuable/continuable-testing.hpp>
|
||||||
#include <continuable/continuable-trait.hpp>
|
#include <continuable/continuable-trait.hpp>
|
||||||
|
#include <continuable/continuable-transforms.hpp>
|
||||||
namespace cti {
|
#include <continuable/continuable-types.hpp>
|
||||||
// clang-format off
|
|
||||||
namespace detail {
|
|
||||||
/// A function which isn't size adjusted and copyable
|
|
||||||
template<std::size_t Size, typename... Args>
|
|
||||||
using function_adapter = fu2::function<Args...>;
|
|
||||||
/// A function which isn't size adjusted and move only
|
|
||||||
template<std::size_t, typename... Args>
|
|
||||||
using unique_function_adapter = fu2::unique_function<Args...>;
|
|
||||||
/// A function which is size adjusted and copyable
|
|
||||||
template<std::size_t Size, typename... Args>
|
|
||||||
using function_adjustable = fu2::function_base<true, true, Size,
|
|
||||||
true, false, Args...>;
|
|
||||||
/// A function which is size adjusted and move only
|
|
||||||
template<std::size_t Size, typename... Args>
|
|
||||||
using unique_function_adjustable = fu2::function_base<true, false, Size,
|
|
||||||
true, false, Args...>;
|
|
||||||
|
|
||||||
/// We adjust the internal capacity of the outer function wrapper so
|
|
||||||
/// we don't have to allocate twice when using `continuable<...>`.
|
|
||||||
template<typename... Args>
|
|
||||||
using trait_of = continuable_trait<
|
|
||||||
unique_function_adapter,
|
|
||||||
function_adjustable,
|
|
||||||
Args...
|
|
||||||
>;
|
|
||||||
|
|
||||||
template<typename... Args>
|
|
||||||
using unique_trait_of = continuable_trait<
|
|
||||||
unique_function_adapter,
|
|
||||||
unique_function_adjustable,
|
|
||||||
Args...
|
|
||||||
>;
|
|
||||||
} // namespace detail
|
|
||||||
|
|
||||||
/// Defines a copyable continuation type which uses the
|
|
||||||
/// function2 backend for type erasure.
|
|
||||||
///
|
|
||||||
/// Usable like: `cti::continuable<int, float>`
|
|
||||||
template <typename... Args>
|
|
||||||
using continuable = typename detail::trait_of<
|
|
||||||
Args...
|
|
||||||
>::continuable;
|
|
||||||
|
|
||||||
/// Defines a non-copyable continuation type which uses the
|
|
||||||
/// function2 backend for type erasure.
|
|
||||||
///
|
|
||||||
/// Usable like: `unique_continuable<int, float>`
|
|
||||||
template <typename... Args>
|
|
||||||
using unique_continuable = typename detail::unique_trait_of<
|
|
||||||
Args...
|
|
||||||
>::continuable;
|
|
||||||
|
|
||||||
/// Defines a non-copyable promise type which is using the
|
|
||||||
/// function2 backend for type erasure.
|
|
||||||
///
|
|
||||||
/// Usable like: `promise<int, float>`
|
|
||||||
template <typename... Args>
|
|
||||||
using promise = typename detail::unique_trait_of<
|
|
||||||
Args...
|
|
||||||
>::promise;
|
|
||||||
|
|
||||||
// TODO channel
|
|
||||||
// TODO sink
|
|
||||||
|
|
||||||
// clang-format on
|
|
||||||
} // namespace cti
|
|
||||||
|
|
||||||
#endif // CONTINUABLE_HPP_INCLUDED__
|
#endif // CONTINUABLE_HPP_INCLUDED__
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
set(LIB_SOURCES
|
set(LIB_SOURCES
|
||||||
${CMAKE_SOURCE_DIR}/include/continuable/continuable-api.hpp
|
${CMAKE_SOURCE_DIR}/include/continuable/continuable-api.hpp
|
||||||
${CMAKE_SOURCE_DIR}/include/continuable/continuable.hpp
|
${CMAKE_SOURCE_DIR}/include/continuable/continuable.hpp
|
||||||
|
${CMAKE_SOURCE_DIR}/include/continuable/continuable-types.hpp
|
||||||
${CMAKE_SOURCE_DIR}/include/continuable/continuable-base.hpp
|
${CMAKE_SOURCE_DIR}/include/continuable/continuable-base.hpp
|
||||||
${CMAKE_SOURCE_DIR}/include/continuable/continuable-trait.hpp
|
${CMAKE_SOURCE_DIR}/include/continuable/continuable-trait.hpp
|
||||||
${CMAKE_SOURCE_DIR}/include/continuable/continuable-promise-base.hpp
|
${CMAKE_SOURCE_DIR}/include/continuable/continuable-promise-base.hpp
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user