Hi,
Is it possible to launch a thread in a coroutine? Such that this code
would work:
#include <iostream>
#include <thread>
#include
std::thread t;
void push_data2(boost::coroutines::coroutinestd::string::push_type sink)
{
sink("test2");
}
void push_data(boost::coroutines::coroutinestd::string::push_type& sink)
{
sink("test1");
t = std::thread(push_data2, std::move(sink));
}
int main()
{
boost::coroutines::coroutinestd::string::pull_type source(push_data);
auto b = boost::begin(source);
auto e = boost::end(source);
std::cout << *b << std::endl;
++b;
std::cout << *b << std::endl;
t.join()
return 0;
}
Output:
test1
parser: /usr/local/include/boost/smart_ptr/intrusive_ptr.hpp:162: T*
boost::intrusive_ptr<T>::operator->() const [with T =
boost::coroutines::detail::push_coroutine_base
]: Assertion `px != 0' failed.
Aborted (core dumped)