Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r57691 - sandbox/fiber/libs/fiber/examples
From: oliver.kowalke_at_[hidden]
Date: 2009-11-15 15:23:13


Author: olli
Date: 2009-11-15 15:23:12 EST (Sun, 15 Nov 2009)
New Revision: 57691
URL: http://svn.boost.org/trac/boost/changeset/57691

Log:
- example related to multi-threading removed

Removed:
   sandbox/fiber/libs/fiber/examples/simple_mt.cpp
Text files modified:
   sandbox/fiber/libs/fiber/examples/Jamfile.v2 | 1 -
   1 files changed, 0 insertions(+), 1 deletions(-)

Modified: sandbox/fiber/libs/fiber/examples/Jamfile.v2
==============================================================================
--- sandbox/fiber/libs/fiber/examples/Jamfile.v2 (original)
+++ sandbox/fiber/libs/fiber/examples/Jamfile.v2 2009-11-15 15:23:12 EST (Sun, 15 Nov 2009)
@@ -27,5 +27,4 @@
 exe join : join.cpp ;
 exe cancel : cancel.cpp ;
 exe simple : simple.cpp ;
-exe simple_mt : simple_mt.cpp ;
 exe ping_pong : ping_pong.cpp ;

Deleted: sandbox/fiber/libs/fiber/examples/simple_mt.cpp
==============================================================================
--- sandbox/fiber/libs/fiber/examples/simple_mt.cpp 2009-11-15 15:23:12 EST (Sun, 15 Nov 2009)
+++ (empty file)
@@ -1,80 +0,0 @@
-#include <cstdlib>
-#include <iostream>
-#include <sstream>
-#include <string>
-
-#include <boost/bind.hpp>
-#include <boost/ref.hpp>
-#include <boost/system/system_error.hpp>
-#include <boost/thread.hpp>
-
-#include <boost/fiber.hpp>
-
-void f( std::string const& str, int n)
-{
- for ( int i = 0; i < n; ++i)
- {
- std::ostringstream os1;
- std::ostringstream os2;
- os1 << boost::this_thread::get_id();
- os2 << boost::this_fiber::get_id();
- fprintf( stderr, "(thread: %s, fiber: %s) %d: %s\n", os1.str().c_str(), os2.str().c_str(), i, str.c_str() );
- boost::this_fiber::yield();
- }
-}
-
-void run_thread(
- boost::barrier & b,
- boost::fibers::scheduler & sched,
- std::string const& msg, int n)
-{
- std::ostringstream os;
- os << boost::this_thread::get_id();
- fprintf( stderr, "start (thread: %s)\n", os.str().c_str() );
- sched.make_fiber( & f, msg, n);
-
- b.wait();
- for (;;)
- {
- while ( sched.run() );
- if ( sched.empty() ) break;
- }
-
- fprintf( stderr, "finish (thread: %s)\n", os.str().c_str() );
-}
-
-int main()
-{
- try
- {
- boost::fibers::scheduler sched;
-
- std::cout << "start" << std::endl;
-
- boost::barrier b( 2);
- boost::thread th1(
- run_thread,
- boost::ref( b),
- boost::ref( sched), "abc", 3);
- boost::thread th2(
- run_thread,
- boost::ref( b),
- boost::ref( sched), "xyz", 4);
-
- th1.join();
- th2.join();
-
- std::cout << "finish" << std::endl;
-
- return EXIT_SUCCESS;
- }
- catch ( boost::system::system_error const& e)
- { std::cerr << "system_error: " << e.code().value() << std::endl; }
- catch ( boost::fibers::scheduler_error const& e)
- { std::cerr << "scheduler_error: " << e.what() << std::endl; }
- catch ( std::exception const& e)
- { std::cerr << "exception: " << e.what() << std::endl; }
- catch (...)
- { std::cerr << "unhandled exception" << std::endl; }
- return EXIT_FAILURE;
-}


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk