Skip to content

Commit 2b91c3f

Browse files
authored
Merge pull request NVIDIA#1458 from NVIDIA/no-alloc-co_await-for-exec-task
increase the size of the small-object buffer for type-erased operation states
2 parents 5f01147 + b5bdbbf commit 2b91c3f

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

include/exec/any_sender_of.hpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -567,8 +567,13 @@ namespace exec {
567567
}
568568
};
569569

570-
template <class _VTable = __empty_vtable, class _Allocator = std::allocator<std::byte>>
571-
using __immovable_storage_t = __t<__immovable_storage<_VTable, _Allocator>>;
570+
template <
571+
class _VTable = __empty_vtable,
572+
class _Allocator = std::allocator<std::byte>,
573+
std::size_t _InlineSize = 3 * sizeof(void*),
574+
std::size_t _Alignment = alignof(std::max_align_t)>
575+
using __immovable_storage_t =
576+
__t<__immovable_storage<_VTable, _Allocator, _InlineSize, _Alignment>>;
572577

573578
template <class _VTable, class _Allocator = std::allocator<std::byte>>
574579
using __unique_storage_t = __t<__storage<_VTable, _Allocator>>;
@@ -791,7 +796,8 @@ namespace exec {
791796
}
792797
};
793798

794-
using __immovable_operation_storage = __immovable_storage_t<__operation_vtable>;
799+
using __immovable_operation_storage =
800+
__immovable_storage_t<__operation_vtable, std::allocator<std::byte>, 6 * sizeof(void*)>;
795801

796802
template <class _Sigs, class _Queries>
797803
using __receiver_ref = __mapply<__mbind_front<__q<__rec::__ref>, _Sigs>, _Queries>;
@@ -1205,6 +1211,7 @@ namespace exec {
12051211

12061212
template <auto... _SchedulerQueries>
12071213
class any_scheduler {
1214+
// Add the required set_value_t() completions to the schedule-sender.
12081215
using __schedule_completions = stdexec::__concat_completion_signatures<
12091216
_Completions,
12101217
stdexec::completion_signatures<stdexec::set_value_t()>>;
@@ -1216,10 +1223,11 @@ namespace exec {
12161223
template <class _Tag>
12171224
struct __ret_equals_to {
12181225
template <class _Sig>
1219-
using __f = std::is_same<_Tag, decltype(__ret_fn(static_cast<_Sig>(nullptr)))>;
1226+
using __f =
1227+
stdexec::__mbool<STDEXEC_IS_SAME(_Tag, decltype(__ret_fn(static_cast<_Sig>(nullptr))))>;
12201228
};
12211229

1222-
using schedule_sender_queries = stdexec::__minvoke<
1230+
using __schedule_sender_queries = stdexec::__minvoke<
12231231
stdexec::__mremove_if<
12241232
__ret_equals_to<stdexec::get_completion_scheduler_t<stdexec::set_value_t>>>,
12251233
decltype(_SenderQueries)...>;
@@ -1238,7 +1246,7 @@ namespace exec {
12381246
stdexec::get_completion_scheduler<stdexec::set_value_t>.template signature<any_scheduler() noexcept>>;
12391247
#endif
12401248
using __schedule_sender =
1241-
stdexec::__mapply<stdexec::__q<__schedule_sender_fn>, schedule_sender_queries>;
1249+
stdexec::__mapply<stdexec::__q<__schedule_sender_fn>, __schedule_sender_queries>;
12421250

12431251
using __scheduler_base =
12441252
__any::__scheduler<__schedule_sender, queries<_SchedulerQueries...>>;

include/exec/task.hpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,14 @@ namespace exec {
3838
namespace __task {
3939
using namespace stdexec;
4040

41-
using __any_scheduler = //
42-
any_receiver_ref< //
43-
completion_signatures<set_error_t(std::exception_ptr), set_stopped_t()> //
44-
>::any_sender<>::any_scheduler<>;
41+
// The required set_value_t() scheduler-sender completion signature is added in
42+
// any_receiver_ref::any_sender::any_scheduler.
43+
using __any_scheduler_completions =
44+
completion_signatures<set_error_t(std::exception_ptr), set_stopped_t()>;
45+
46+
using __any_scheduler =
47+
any_receiver_ref<__any_scheduler_completions>::any_sender<>::any_scheduler<>;
48+
4549
static_assert(scheduler<__any_scheduler>);
4650

4751
template <class _Ty>

0 commit comments

Comments
 (0)