-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from beman-project/basic-sender
Basic sender
- Loading branch information
Showing
6 changed files
with
339 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// include/beman/execution26/detail/get_domain_early.hpp -*-C++-*- | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
#ifndef INCLUDED_BEMAN_EXECUTION26_DETAIL_GET_DOMAIN_EARLY | ||
#define INCLUDED_BEMAN_EXECUTION26_DETAIL_GET_DOMAIN_EARLY | ||
|
||
#include <beman/execution26/detail/completion_domain.hpp> | ||
#include <beman/execution26/detail/default_domain.hpp> | ||
#include <beman/execution26/detail/get_domain.hpp> | ||
#include <beman/execution26/detail/get_env.hpp> | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
namespace beman::execution26::detail | ||
{ | ||
template <typename Sender> | ||
constexpr auto get_domain_early(Sender const& sender) noexcept | ||
{ | ||
if constexpr (requires{ | ||
::beman::execution26::get_domain( | ||
::beman::execution26::get_env(sender) | ||
); | ||
}) | ||
return decltype( | ||
::beman::execution26::get_domain( | ||
::beman::execution26::get_env(sender) | ||
) | ||
){}; | ||
else if constexpr (requires{ | ||
::beman::execution26::detail::completion_domain(sender); | ||
}) | ||
return decltype(::beman::execution26::detail::completion_domain(sender)){}; | ||
else | ||
return ::beman::execution26::default_domain{}; | ||
} | ||
} | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
#endif |
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,35 @@ | ||
// include/beman/execution26/detail/make_sender.hpp -*-C++-*- | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
#ifndef INCLUDED_BEMAN_EXECUTION26_DETAIL_MAKE_SENDER | ||
#define INCLUDED_BEMAN_EXECUTION26_DETAIL_MAKE_SENDER | ||
|
||
#include <beman/execution26/detail/basic_sender.hpp> | ||
#include <beman/execution26/detail/movable_value.hpp> | ||
#include <beman/execution26/detail/sender.hpp> | ||
#include <concepts> | ||
#include <type_traits> | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
namespace beman::execution26::detail | ||
{ | ||
struct make_sender_empty {}; | ||
|
||
template <typename Tag, | ||
typename Data = ::beman::execution26::detail::make_sender_empty, | ||
typename... Child> | ||
requires ::std::semiregular<Tag> | ||
&& ::beman::execution26::detail::movable_value<Data> | ||
&& (::beman::execution26::sender<Child> && ...) | ||
constexpr auto make_sender(Tag tag, Data&& data, Child&&... child) | ||
{ | ||
return ::beman::execution26::detail::basic_sender< | ||
Tag, ::std::decay_t<Data>, ::std::decay_t<Child>... | ||
>{tag, ::std::forward<Data>(data), child...}; | ||
} | ||
} | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
#endif |
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,61 @@ | ||
// include/beman/execution26/detail/sender_adaptor.hpp -*-C++-*- | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
#ifndef INCLUDED_BEMAN_EXECUTION26_DETAIL_SENDER_ADAPTOR | ||
#define INCLUDED_BEMAN_EXECUTION26_DETAIL_SENDER_ADAPTOR | ||
|
||
#include <beman/execution26/detail/sender.hpp> | ||
#include <beman/execution26/detail/sender_adaptor_closure.hpp> | ||
#include <beman/execution26/detail/sender_decompose.hpp> | ||
#include <beman/execution26/detail/product_type.hpp> | ||
#include <type_traits> | ||
#include <utility> | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
namespace beman::execution26::detail | ||
{ | ||
template <typename Adaptor, typename T0, typename... T> | ||
struct sender_adaptor | ||
: ::beman::execution26::detail::product_type< | ||
::std::decay_t<Adaptor>, ::std::decay_t<T0>, ::std::decay_t<T>...> | ||
, ::beman::execution26::sender_adaptor_closure<sender_adaptor<Adaptor, T0, T...>> | ||
{ | ||
template <::beman::execution26::sender Sender> | ||
static auto apply(Sender&& sender, auto&& self) | ||
{ | ||
using base_type = ::beman::execution26::detail::product_type< | ||
::std::decay_t<Adaptor>, ::std::decay_t<T0>, ::std::decay_t<T>...>; | ||
static constexpr ::beman::execution26::detail::sender_any_t at{}; | ||
if constexpr (requires{ base_type{ at, at, at, at }; }) | ||
{ | ||
auto&&[adaptor, arg0, arg1, arg2] = self; | ||
return adaptor(::std::forward<Sender>(sender), arg0, arg1, arg2); | ||
} | ||
if constexpr (requires{ base_type{ at, at, at }; }) | ||
{ | ||
auto&&[adaptor, arg0, arg1] = self; | ||
return adaptor(::std::forward<Sender>(sender), arg0, arg1); | ||
} | ||
else if constexpr (requires{ base_type{ at, at }; }) | ||
{ | ||
auto&&[adaptor, arg0] = self; | ||
return adaptor(::std::forward<Sender>(sender), arg0); | ||
} | ||
} | ||
template <::beman::execution26::sender Sender> | ||
auto operator()(Sender&& sender) | ||
{ | ||
return apply(::std::forward<Sender>(sender), *this); | ||
} | ||
template <::beman::execution26::sender Sender> | ||
auto operator()(Sender&& sender) const | ||
{ | ||
return apply(::std::forward<Sender>(sender), *this); | ||
} | ||
}; | ||
} | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
#endif |
46 changes: 46 additions & 0 deletions
46
include/beman/execution26/detail/sender_adaptor_closure.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// include/beman/execution26/detail/sender_adaptor_closure.hpp -*-C++-*- | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
#ifndef INCLUDED_BEMAN_EXECUTION26_DETAIL_SENDER_ADAPTOR_CLOSURE | ||
#define INCLUDED_BEMAN_EXECUTION26_DETAIL_SENDER_ADAPTOR_CLOSURE | ||
|
||
#include <beman/execution26/detail/sender.hpp> | ||
#include <concepts> | ||
#include <type_traits> | ||
#include <utility> | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
namespace beman::execution26::detail::pipeable | ||
{ | ||
struct sender_adaptor_closure_base {}; | ||
} | ||
|
||
namespace beman::execution26 | ||
{ | ||
template <typename> | ||
struct sender_adaptor_closure | ||
: ::beman::execution26::detail::pipeable::sender_adaptor_closure_base | ||
{ | ||
}; | ||
} | ||
|
||
namespace beman::execution26::detail::pipeable | ||
{ | ||
template <::beman::execution26::sender Sender, typename Adaptor> | ||
requires (not ::beman::execution26::sender<Adaptor>) | ||
&& ::std::derived_from<::std::decay_t<Adaptor>, | ||
::beman::execution26::sender_adaptor_closure<::std::decay_t<Adaptor>>> | ||
&& requires(Sender&& sender, Adaptor&& adaptor) | ||
{ | ||
{ adaptor(::std::forward<Sender>(sender)) } -> ::beman::execution26::sender; | ||
} | ||
auto operator| (Sender&& sender, Adaptor&& adaptor) | ||
{ | ||
return adaptor(::std::forward<Sender>(sender)); | ||
} | ||
} | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
#endif |
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.