Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 29 additions & 28 deletions include/exec/static_thread_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,10 @@ namespace experimental::execution
class CvSender>
auto operator()(Tag, Data&& data, CvSender&& sndr) const
{
auto [pol, shape, fun] = static_cast<Data&&>(data);
using policy_t = std::remove_cvref_t<decltype(pol.__get())>;
constexpr bool parallelize = std::same_as<policy_t, parallel_policy>
|| std::same_as<policy_t, parallel_unsequenced_policy>;
auto [pol, shape, fun] = static_cast<Data&&>(data);
using policy_t = std::remove_cvref_t<decltype(pol.__get())>;
constexpr bool parallelize =
__one_of<policy_t, parallel_policy, parallel_unsequenced_policy>;

if constexpr (__same_as<Tag, bulk_unchunked_t>)
{
Expand Down Expand Up @@ -291,11 +291,14 @@ namespace experimental::execution
constexpr auto
transform_sender(STDEXEC::set_value_t, Sender&& sndr, Env const & env) const noexcept
{
if constexpr (__completes_on<Sender, _static_thread_pool::scheduler, Env>)
auto& [tag, data, child] = sndr;
auto& [pol, shape, fun] = data;

if constexpr (__completes_on<decltype(child), scheduler, Env>)
{
auto sched = STDEXEC::get_completion_scheduler<STDEXEC::set_value_t>(get_env(sndr),
auto sched = STDEXEC::get_completion_scheduler<STDEXEC::set_value_t>(get_env(child),
env);
static_assert(std::is_same_v<decltype(sched), _static_thread_pool::scheduler>);
static_assert(std::is_same_v<decltype(sched), scheduler>);
return __apply(_transform_bulk{*sched.pool_}, static_cast<Sender&&>(sndr));
}
else
Expand All @@ -316,7 +319,7 @@ namespace experimental::execution
constexpr auto
transform_sender(STDEXEC::set_value_t, Sender&& sndr, Env const & env) const noexcept
{
if constexpr (__completes_on<Sender, _static_thread_pool::scheduler, Env>)
if constexpr (__completes_on<Sender, scheduler, Env>)
{
auto sched = STDEXEC::get_completion_scheduler<STDEXEC::set_value_t>(get_env(sndr),
env);
Expand Down Expand Up @@ -357,10 +360,9 @@ namespace experimental::execution
struct attrs
{
template <class CPO>
auto query(get_completion_scheduler_t<CPO>, __ignore = {}) const noexcept
-> _static_thread_pool::scheduler
auto query(get_completion_scheduler_t<CPO>, __ignore = {}) const noexcept -> scheduler
{
return _static_thread_pool::scheduler{pool_, *queue_};
return scheduler{pool_, *queue_};
}

template <class CPO>
Expand Down Expand Up @@ -402,7 +404,7 @@ namespace experimental::execution
}

private:
friend struct _static_thread_pool::scheduler;
friend struct scheduler;

explicit _sender(_static_thread_pool& pool,
remote_queue* queue,
Expand Down Expand Up @@ -1215,7 +1217,7 @@ namespace experimental::execution
}

private:
friend class ::exec::_pool_::_static_thread_pool::scheduler::_sender;
friend class scheduler::_sender;

explicit _opstate(_static_thread_pool& pool,
remote_queue* queue,
Expand Down Expand Up @@ -1491,26 +1493,25 @@ namespace experimental::execution
STDEXEC_TRY
{
shared_state_.data_.template emplace<__decayed_tuple<As...>>(static_cast<As&&>(as)...);

if (Shape{} < shared_state_.shape_)
{
enqueue();
}
else
{
__visit(STDEXEC::__flip(std::bind_front(__apply, STDEXEC::set_value)),
std::move(shared_state_.data_),
static_cast<Receiver&&>(shared_state_.rcvr_));
}
}
STDEXEC_CATCH_ALL
{
if constexpr (!__nothrow_decay_copyable<As...>)
{
if constexpr (__nothrow_decay_copyable<As...>)
STDEXEC::__std::unreachable();
else
STDEXEC::set_error(static_cast<Receiver&&>(shared_state_.rcvr_),
std::current_exception());
return;
}
}

if (Shape{} < shared_state_.shape_)
{
enqueue();
}
else
{
__visit(STDEXEC::__flip(std::bind_front(__apply, STDEXEC::set_value)),
std::move(shared_state_.data_),
static_cast<Receiver&&>(shared_state_.rcvr_));
}
}

Expand Down
Loading
Loading