Hello, I'm trying to get along new standard. But when i wrote simple program like this
exec::task<std::string> coro1(int &counter)
{
for (int i = 0; i < 10; i++)
{
counter += 1;
}
co_return std::to_string(counter);
}
exec::task<int> coro2(int &counter)
{
for (int i = 0; i < 10; i++)
{
counter += 1;
}
co_return counter;
}
exec::task<void> main_coro(int &counter)
{
auto [result1, result2] = co_await stdexec::when_all(
coro1(counter),
coro2(counter)
);
std::cout << result1 << " " << result2 << " " << counter;
co_return ;
}
int main() {
exec::static_thread_pool pool(3);
auto scheduler = pool.get_scheduler();
int counter = 50;
stdexec::sync_wait(
stdexec::when_all(
stdexec::starts_on(scheduler, main_coro(counter))
)
);
}
I have a runtime error:
testAsync: /cmake-build-debug/_deps/stdexec-src/include/stdexec/__detail/__any.hpp:636: virtual void
stdexec::__any::__value_model<experimental::execution::_any::_ischeduler<experimental::execution::any_sender<experimental::execution::any_receiver<stdexec::completion_signatures<stdexec::set_value_t (), stdexec::set_error_t (std::__exception_ptr::exception_ptr), stdexec::set_stopped_t ()>>>,
experimental::execution::queries<>>::_interface_, experimental::execution::_pool_::_static_thread_pool::scheduler,
std::allocator<experimental::execution::_pool_::_static_thread_pool::scheduler>>::__move_to(__iroot *&, std::span<std::byte>) [_Interface =
experimental::execution::_any::_ischeduler<experimental::execution::any_sender<experimental::execution::any_receiver<stdexec::completion_signatures<stdexec::set_value_t (), stdexec::set_error_t (std::__exception_ptr::exception_ptr), stdexec::set_stopped_t ()>>>,
experimental::execution::queries<>>::_interface_, _Value = experimental::execution::_pool_::_static_thread_pool::scheduler, _Allocator =
std::allocator<experimental::execution::_pool_::_static_thread_pool::scheduler>]: Assertion
`stdexec::__any::__is_small<__value_model>(__buff.size())' failed.
I made some experiments and think that size of static_thread_pool is more than any::__default_buffer_size, so it doesn't fit. If i use another schedulers (for example asio) - it compile and run perfectly. Is it expected behavior, or i doing something wrong
Hello, I'm trying to get along new standard. But when i wrote simple program like this
I have a runtime error:
I made some experiments and think that size of static_thread_pool is more than any::__default_buffer_size, so it doesn't fit. If i use another schedulers (for example asio) - it compile and run perfectly. Is it expected behavior, or i doing something wrong