Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r57443 - in sandbox/fiber: boost/fiber boost/fiber/detail libs/fiber/src
From: oliver.kowalke_at_[hidden]
Date: 2009-11-07 02:47:43


Author: olli
Date: 2009-11-07 02:47:42 EST (Sat, 07 Nov 2009)
New Revision: 57443
URL: http://svn.boost.org/trac/boost/changeset/57443

Log:
- new exceptions fiber_error added
- fiber_error thrown if not a fiber

Text files modified:
   sandbox/fiber/boost/fiber/detail/scheduler_data.hpp | 8 ++++----
   sandbox/fiber/boost/fiber/exceptions.hpp | 8 ++++++++
   sandbox/fiber/libs/fiber/src/scheduler.cpp | 24 ++++++++++++------------
   3 files changed, 24 insertions(+), 16 deletions(-)

Modified: sandbox/fiber/boost/fiber/detail/scheduler_data.hpp
==============================================================================
--- sandbox/fiber/boost/fiber/detail/scheduler_data.hpp (original)
+++ sandbox/fiber/boost/fiber/detail/scheduler_data.hpp 2009-11-07 02:47:42 EST (Sat, 07 Nov 2009)
@@ -27,15 +27,15 @@
         fiber master;
         fiber::id f_id;
         ptr_map< fiber::id, fiber > fibers;
- std::queue< fiber::id > run_queue;
- std::queue< fiber::id > zombie_queue;
+ std::queue< fiber::id > runnable_fibers;
+ std::queue< fiber::id > dead_fibers;
 
         scheduler_data() :
                 master(),
                 f_id(),
                 fibers(),
- run_queue(),
- zombie_queue()
+ runnable_fibers(),
+ dead_fibers()
         {}
 };
 

Modified: sandbox/fiber/boost/fiber/exceptions.hpp
==============================================================================
--- sandbox/fiber/boost/fiber/exceptions.hpp (original)
+++ sandbox/fiber/boost/fiber/exceptions.hpp 2009-11-07 02:47:42 EST (Sat, 07 Nov 2009)
@@ -13,6 +13,14 @@
 namespace boost {
 namespace fiber {
 
+class fiber_error : public std::runtime_error
+{
+public:
+ fiber_error( std::string const& msg)
+ : std::runtime_error( msg)
+ {}
+};
+
 class scheduler_error : public std::runtime_error
 {
 public:

Modified: sandbox/fiber/libs/fiber/src/scheduler.cpp
==============================================================================
--- sandbox/fiber/libs/fiber/src/scheduler.cpp (original)
+++ sandbox/fiber/libs/fiber/src/scheduler.cpp 2009-11-07 02:47:42 EST (Sat, 07 Nov 2009)
@@ -22,7 +22,7 @@
 scheduler::get_id()
 {
         detail::scheduler_data * dt( data.get() );
- BOOST_ASSERT( dt);
+ if ( ! dt) throw fiber_error("not a fiber");
         return dt->f_id;
 }
 
@@ -30,8 +30,8 @@
 scheduler::yield()
 {
         detail::scheduler_data * dt( data.get() );
- BOOST_ASSERT( dt);
- dt->run_queue.push( dt->f_id);
+ if ( ! dt) throw fiber_error("not a fiber");
+ dt->runnable_fibers.push( dt->f_id);
         dt->fibers[dt->f_id].switch_to( dt->master);
 }
 
@@ -39,8 +39,8 @@
 scheduler::exit()
 {
         detail::scheduler_data * dt( data.get() );
- BOOST_ASSERT( dt);
- dt->zombie_queue.push( dt->f_id);
+ if ( ! dt) throw fiber_error("not a fiber");
+ dt->dead_fibers.push( dt->f_id);
         dt->fibers[dt->f_id].switch_to( dt->master);
 }
 
@@ -67,7 +67,7 @@
         std::pair< ptr_map< detail::fiber::id, detail::fiber >::iterator, bool > result(
                 dt->fibers.insert( id, f) );
         if ( ! result.second) throw scheduler_error("inserting fiber failed");
- dt->run_queue.push( result.first->first);
+ dt->runnable_fibers.push( result.first->first);
 }
 
 bool
@@ -75,17 +75,17 @@
 {
         detail::scheduler_data * dt = access_data();
 
- if ( ! dt->run_queue.empty() )
+ if ( ! dt->runnable_fibers.empty() )
         {
- dt->f_id = dt->run_queue.front();
+ dt->f_id = dt->runnable_fibers.front();
                 dt->master.switch_to( dt->fibers[dt->f_id]);
- dt->run_queue.pop();
+ dt->runnable_fibers.pop();
                 return true;
         }
- if ( ! dt->zombie_queue.empty() )
+ if ( ! dt->dead_fibers.empty() )
         {
- dt->fibers.erase( dt->zombie_queue.front() );
- dt->zombie_queue.pop();
+ dt->fibers.erase( dt->dead_fibers.front() );
+ dt->dead_fibers.pop();
                 return true;
         }
         return false;


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