]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/fiber/test/test_barrier_dispatch.cpp
2 // Copyright Oliver Kowalke 2013.
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
7 // This test is based on the tests of Boost.Thread
12 #include <boost/test/unit_test.hpp>
14 #include <boost/fiber/all.hpp>
19 void fn1( boost::fibers::barrier
& b
) {
21 boost::this_fiber::yield();
26 boost::this_fiber::yield();
28 boost::this_fiber::yield();
30 boost::this_fiber::yield();
34 void fn2( boost::fibers::barrier
& b
) {
36 boost::this_fiber::yield();
38 boost::this_fiber::yield();
40 boost::this_fiber::yield();
45 boost::this_fiber::yield();
53 boost::fibers::barrier
b( 2);
54 boost::fibers::fiber
f1( boost::fibers::launch::dispatch
, fn1
, std::ref( b
) );
55 boost::fibers::fiber
f2( boost::fibers::launch::dispatch
, fn2
, std::ref( b
) );
60 BOOST_CHECK_EQUAL( 5, value1
);
61 BOOST_CHECK_EQUAL( 5, value2
);
64 boost::unit_test::test_suite
* init_unit_test_suite( int, char* []) {
65 boost::unit_test::test_suite
* test
=
66 BOOST_TEST_SUITE("Boost.Fiber: barrier test suite");
68 test
->add( BOOST_TEST_CASE( & test_barrier
) );