Beispiel #1
0
int main()
{
    boost::asio::io_service io_service;
    boost::asio::io_service::strand strand1(io_service);
    boost::asio::io_service::strand strand2(io_service);
    boost::asio::io_service::strand strand3(strand1);

    boost::asio::spawn(strand1,
                       [&](boost::asio::yield_context yield)
    {
        assert(strand1.running_in_this_thread());
        assert(!strand2.running_in_this_thread());
        assert(strand3.running_in_this_thread());

        // Access implementation details.
        auto strand4 = yield.handler_.dispatcher_;
        assert(strand4.running_in_this_thread());

        // No way to compare strands to one another.  Although strand1, strand3,
        // and strand4 use the same strand implementation, there is no way to
        // compare the objects themselves to one another.
    });

    io_service.run();
}
bool boost_strand::empty(bool checkTick)
{
	assert(_strand);
	assert(running_in_this_thread());
#ifdef ENABLE_NEXT_TICK
	return _strand->empty() && (checkTick ? _nextTickQueue1.empty() && _nextTickQueue2.empty() : true);
#else
	return _strand->empty();
#endif
}
bool qt_strand::in_this_ios()
{
	return running_in_this_thread();
}