From 4b604ff93adf1da99e11666f0bca36e6e6d4790c Mon Sep 17 00:00:00 2001 From: Oliver Kowalke Date: Thu, 21 Aug 2014 17:28:28 +0200 Subject: [PATCH] test for multiple definitions --- examples/cpp03/Jamfile.v2 | 4 ++-- examples/cpp03/test_fiber.cpp | 23 +++++++++++++++++++++++ examples/cpp03/test_future.cpp | 24 ++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 examples/cpp03/test_fiber.cpp create mode 100644 examples/cpp03/test_future.cpp diff --git a/examples/cpp03/Jamfile.v2 b/examples/cpp03/Jamfile.v2 index 289eda22..cc58d7c9 100644 --- a/examples/cpp03/Jamfile.v2 +++ b/examples/cpp03/Jamfile.v2 @@ -31,13 +31,13 @@ project boost/fiber/example ; exe barrier : barrier.cpp ; -exe future : future.cpp ; +exe future : future.cpp test_future.cpp ; exe futures_mt : futures_mt.cpp ; exe interrupt : interrupt.cpp ; exe join : join.cpp ; exe ping_pong : ping_pong.cpp ; exe segmented_stack : segmented_stack.cpp ; -exe simple : simple.cpp ; +exe simple : simple.cpp test_fiber.cpp ; exe migrate_fibers : migrate_fibers.cpp workstealing_round_robin.cpp diff --git a/examples/cpp03/test_fiber.cpp b/examples/cpp03/test_fiber.cpp new file mode 100644 index 00000000..e3176c38 --- /dev/null +++ b/examples/cpp03/test_fiber.cpp @@ -0,0 +1,23 @@ +#include + +#include + +#include + +void foo( std::string const& str, int n) +{ + for ( int i = 0; i < n; ++i) + { + std::cout << i << ": " << str << std::endl; + boost::this_fiber::yield(); + } +} + +void bar() +{ + boost::fibers::fiber f1( boost::bind( foo, "abc", 5) ); + boost::fibers::fiber f2( boost::bind( foo, "xyz", 7) ); + + f1.join(); + f2.join(); +} diff --git a/examples/cpp03/test_future.cpp b/examples/cpp03/test_future.cpp new file mode 100644 index 00000000..7ff5cb34 --- /dev/null +++ b/examples/cpp03/test_future.cpp @@ -0,0 +1,24 @@ +#include + +#include + +#include + +int foo( std::string const& str, int n) +{ + for ( int i = 0; i < n; ++i) + { + std::cout << i << ": " << str << std::endl; + boost::this_fiber::yield(); + } + + return n; +} + +void bar() +{ + boost::fibers::future< int > fi( + boost::fibers::async( + boost::bind( foo, "abc", 5) ) ); + fi.wait(); +}