Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r52616 - in trunk: boost/statechart libs/statechart/doc libs/statechart/test
From: ahd6974-boostorg_at_[hidden]
Date: 2009-04-26 19:15:56


Author: andreas_huber69
Date: 2009-04-26 19:15:55 EDT (Sun, 26 Apr 2009)
New Revision: 52616
URL: http://svn.boost.org/trac/boost/changeset/52616

Log:
Fixed a bug that prevented the use of boost::ref() with fifo_scheduler<>::create_processor<>, reported by Steve Hawkes.
Text files modified:
   trunk/boost/statechart/processor_container.hpp | 80 ++++++++++++++++++++-------
   trunk/libs/statechart/doc/acknowledgments.html | 11 ++-
   trunk/libs/statechart/doc/future_and_history.html | 7 ++
   trunk/libs/statechart/test/FifoSchedulerTest.cpp | 114 ++++++++++++++++++++++++++++++---------
   4 files changed, 158 insertions(+), 54 deletions(-)

Modified: trunk/boost/statechart/processor_container.hpp
==============================================================================
--- trunk/boost/statechart/processor_container.hpp (original)
+++ trunk/boost/statechart/processor_container.hpp 2009-04-26 19:15:55 EDT (Sun, 26 Apr 2009)
@@ -12,6 +12,7 @@
 #include <boost/statechart/event_processor.hpp>
 
 #include <boost/assert.hpp>
+#include <boost/ref.hpp>
 #include <boost/noncopyable.hpp>
 #include <boost/intrusive_ptr.hpp>
 #include <boost/shared_ptr.hpp>
@@ -43,6 +44,28 @@
   typedef event_processor< Scheduler > processor_base_type;
   typedef std::auto_ptr< processor_base_type > processor_holder_type;
   typedef shared_ptr< processor_holder_type > processor_holder_ptr_type;
+
+ template<bool IsReferenceWrapper>
+ struct unwrap_impl
+ {
+ template< typename T >
+ struct apply { typedef T type; };
+ };
+
+ template<>
+ struct unwrap_impl<true>
+ {
+ template< typename T >
+ struct apply { typedef typename T::type & type; };
+ };
+
+ template<typename T>
+ struct unwrap
+ {
+ typedef typename unwrap_impl<
+ is_reference_wrapper< T >::value >::template apply< T >::type type;
+ };
+
   public:
     //////////////////////////////////////////////////////////////////////////
     typedef weak_ptr< processor_holder_type > processor_handle;
@@ -102,10 +125,11 @@
       processor_holder_ptr_type pProcessor = make_processor_holder();
       handle = pProcessor;
       typedef void ( processor_container::*impl_fun_ptr )(
- const processor_holder_ptr_type &, const processor_context &, Arg1 );
+ const processor_holder_ptr_type &, const processor_context &,
+ typename unwrap< Arg1 >::type );
       impl_fun_ptr pImpl =
         &processor_container::template create_processor_impl1<
- Processor, Arg1 >;
+ Processor, typename unwrap< Arg1 >::type >;
       return WorkItem(
         bind( pImpl, this, pProcessor, processor_context( scheduler, handle ),
           arg1 ),
@@ -119,11 +143,12 @@
       processor_holder_ptr_type pProcessor = make_processor_holder();
       handle = pProcessor;
       typedef void ( processor_container::*impl_fun_ptr )(
- const processor_holder_ptr_type &,
- const processor_context &, Arg1, Arg2 );
+ const processor_holder_ptr_type &, const processor_context &,
+ typename unwrap< Arg1 >::type, typename unwrap< Arg2 >::type );
       impl_fun_ptr pImpl =
         &processor_container::template create_processor_impl2<
- Processor, Arg1, Arg2 >;
+ Processor,
+ typename unwrap< Arg1 >::type, typename unwrap< Arg2 >::type >;
       return WorkItem(
         bind( pImpl, this, pProcessor, processor_context( scheduler, handle ),
           arg1, arg2 ),
@@ -138,12 +163,14 @@
       processor_holder_ptr_type pProcessor = make_processor_holder();
       handle = pProcessor;
       typedef void ( processor_container::*impl_fun_ptr )(
- const processor_holder_ptr_type &,
- const processor_context &,
- Arg1, Arg2, Arg3 );
+ const processor_holder_ptr_type &, const processor_context &,
+ typename unwrap< Arg1 >::type, typename unwrap< Arg2 >::type,
+ typename unwrap< Arg3 >::type );
       impl_fun_ptr pImpl =
         &processor_container::template create_processor_impl3<
- Processor, Arg1, Arg2, Arg3 >;
+ Processor,
+ typename unwrap< Arg1 >::type, typename unwrap< Arg2 >::type,
+ typename unwrap< Arg3 >::type >;
       return WorkItem(
         bind( pImpl, this, pProcessor, processor_context( scheduler, handle ),
           arg1, arg2, arg3 ),
@@ -160,12 +187,14 @@
       processor_holder_ptr_type pProcessor = make_processor_holder();
       handle = pProcessor;
       typedef void ( processor_container::*impl_fun_ptr )(
- const processor_holder_ptr_type &,
- const processor_context &,
- Arg1, Arg2, Arg3, Arg4 );
+ const processor_holder_ptr_type &, const processor_context &,
+ typename unwrap< Arg1 >::type, typename unwrap< Arg2 >::type,
+ typename unwrap< Arg3 >::type, typename unwrap< Arg4 >::type );
       impl_fun_ptr pImpl =
         &processor_container::template create_processor_impl4<
- Processor, Arg1, Arg2, Arg3, Arg4 >;
+ Processor,
+ typename unwrap< Arg1 >::type, typename unwrap< Arg2 >::type,
+ typename unwrap< Arg3 >::type, typename unwrap< Arg4 >::type >;
       return WorkItem(
         bind( pImpl, this, pProcessor, processor_context( scheduler, handle ),
           arg1, arg2, arg3, arg4 ),
@@ -182,12 +211,16 @@
       processor_holder_ptr_type pProcessor = make_processor_holder();
       handle = pProcessor;
       typedef void ( processor_container::*impl_fun_ptr )(
- const processor_holder_ptr_type &,
- const processor_context &,
- Arg1, Arg2, Arg3, Arg4, Arg5 );
+ const processor_holder_ptr_type &, const processor_context &,
+ typename unwrap< Arg1 >::type, typename unwrap< Arg2 >::type,
+ typename unwrap< Arg3 >::type, typename unwrap< Arg4 >::type,
+ typename unwrap< Arg5 >::type );
       impl_fun_ptr pImpl =
         &processor_container::template create_processor_impl5<
- Processor, Arg1, Arg2, Arg3, Arg4, Arg5 >;
+ Processor,
+ typename unwrap< Arg1 >::type, typename unwrap< Arg2 >::type,
+ typename unwrap< Arg3 >::type, typename unwrap< Arg4 >::type,
+ typename unwrap< Arg5 >::type >;
       return WorkItem(
         bind( pImpl, this, pProcessor, processor_context( scheduler, handle ),
           arg1, arg2, arg3, arg4, arg5 ),
@@ -204,12 +237,16 @@
       processor_holder_ptr_type pProcessor = make_processor_holder();
       handle = pProcessor;
       typedef void ( processor_container::*impl_fun_ptr )(
- const processor_holder_ptr_type &,
- const processor_context &,
- Arg1, Arg2, Arg3, Arg4, Arg5, Arg6 );
+ const processor_holder_ptr_type &, const processor_context &,
+ typename unwrap< Arg1 >::type, typename unwrap< Arg2 >::type,
+ typename unwrap< Arg3 >::type, typename unwrap< Arg4 >::type,
+ typename unwrap< Arg5 >::type, typename unwrap< Arg6 >::type );
       impl_fun_ptr pImpl =
         &processor_container::template create_processor_impl6<
- Processor, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6 >;
+ Processor,
+ typename unwrap< Arg1 >::type, typename unwrap< Arg2 >::type,
+ typename unwrap< Arg3 >::type, typename unwrap< Arg4 >::type,
+ typename unwrap< Arg5 >::type, typename unwrap< Arg6 >::type >;
       return WorkItem(
         bind( pImpl, this, pProcessor, processor_context( scheduler, handle ),
           arg1, arg2, arg3, arg4, arg5, arg6 ),
@@ -394,7 +431,6 @@
 };
 
 
-
 } // namespace statechart
 } // namespace boost
 

Modified: trunk/libs/statechart/doc/acknowledgments.html
==============================================================================
--- trunk/libs/statechart/doc/acknowledgments.html (original)
+++ trunk/libs/statechart/doc/acknowledgments.html 2009-04-26 19:15:55 EDT (Sun, 26 Apr 2009)
@@ -87,11 +87,12 @@
   <p>Bardur Arantsson, Robert Bell, Bohdan, Wayne Chao, Topher Cooper,
   Philippe David, Peter Dimov, Reece Dunn, John Fuller, Jeff Garland, Eugene
   Gladyshev, David A. Greene, Douglas Gregor, Gustavo Guerra, Aleksey
- Gurtovoy, Federico J. Fern&aacute;ndez, Iain K. Hanson, David B. Held,
- J&uuml;rgen Hunold, Sean Kelly, Oliver Kowalke, Simon Meiklejohn, Jiang
- Miao, Johan Nilsson, Matthieu Paindavoine, Chris Paulse, Yuval Ronen, Chris
- Russell, Bryan Silverthorn, Rob Stewart, Kwee Heong Tan, Marcin Tustin,
- Vincent N. Virgilio, Gang Wang, Steven Watanabe and Scott Woods.</p>
+ Gurtovoy, Federico J. Fern&aacute;ndez, Iain K. Hanson, Steve Hawkes,
+ David B. Held, J&uuml;rgen Hunold, Sean Kelly, Oliver Kowalke, Simon
+ Meiklejohn, Jiang Miao, Johan Nilsson, Matthieu Paindavoine, Chris Paulse,
+ Yuval Ronen, Chris Russell, Bryan Silverthorn, Rob Stewart, Kwee Heong Tan,
+ Marcin Tustin, Vincent N. Virgilio, Gang Wang, Steven Watanabe and Scott
+ Woods.</p>
   <hr>
 
   <p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src=

Modified: trunk/libs/statechart/doc/future_and_history.html
==============================================================================
--- trunk/libs/statechart/doc/future_and_history.html (original)
+++ trunk/libs/statechart/doc/future_and_history.html 2009-04-26 19:15:55 EDT (Sun, 26 Apr 2009)
@@ -140,6 +140,13 @@
 
   <p>(<font color="#FF0000">red</font> = points raised during formal
   review)</p>
+ <p>1.39.0</p>
+ <ul>
+ <li>Fixed a bug that prevented the use of boost::ref() with
+ fifo_scheduler&lt;&gt::create_processor&lt;&gt, reported by Steve
+ Hawkes</li>
+ </ul>
+
   <p>1.38.0</p>
   <ul>
     <li>Fixed gcc-4.3 warning in state_machine.hpp (ticket #2389), reported by

Modified: trunk/libs/statechart/test/FifoSchedulerTest.cpp
==============================================================================
--- trunk/libs/statechart/test/FifoSchedulerTest.cpp (original)
+++ trunk/libs/statechart/test/FifoSchedulerTest.cpp 2009-04-26 19:15:55 EDT (Sun, 26 Apr 2009)
@@ -160,14 +160,30 @@
   }
 }
 
+static int refArg1;
+static int refArg2;
+static int refArg3;
+static int refArg4;
+static int refArg5;
+static int refArg6;
+
 void Check(
   sc::fifo_scheduler<> & scheduler,
   const sc::fifo_scheduler<>::processor_handle & processor,
   int ctorArgs )
 {
+ refArg1 = 6;
+ refArg2 = 5;
+ refArg3 = 4;
+ refArg4 = 3;
+ refArg5 = 2;
+ refArg6 = 1;
+
   // Make sure the processor has been created
   RunScheduler( scheduler, 1UL );
 
+ refArg1 = refArg2 = refArg3 = refArg4 = refArg5 = refArg6 = 0;
+
   scheduler.initiate_processor( processor );
   // This event triggers the queueing of another event, which itself
   // terminates the machine ...
@@ -209,33 +225,77 @@
   try
   {
     sc::fifo_scheduler<> scheduler;
- const sc::fifo_scheduler<>::processor_handle processor0 =
- scheduler.create_processor< FifoSchedulerTest >();
- Check( scheduler, processor0, 0 );
-
- const sc::fifo_scheduler<>::processor_handle processor1 =
- scheduler.create_processor< FifoSchedulerTest >( 1 );
- Check( scheduler, processor1, 1 );
-
- const sc::fifo_scheduler<>::processor_handle processor2 =
- scheduler.create_processor< FifoSchedulerTest >( 1, 2 );
- Check( scheduler, processor2, 12 );
-
- const sc::fifo_scheduler<>::processor_handle processor3 =
- scheduler.create_processor< FifoSchedulerTest >( 1, 2, 3 );
- Check( scheduler, processor3, 123 );
-
- const sc::fifo_scheduler<>::processor_handle processor4 =
- scheduler.create_processor< FifoSchedulerTest >( 1, 2, 3, 4 );
- Check( scheduler, processor4, 1234 );
-
- const sc::fifo_scheduler<>::processor_handle processor5 =
- scheduler.create_processor< FifoSchedulerTest >( 1, 2, 3, 4, 5 );
- Check( scheduler, processor5, 12345 );
-
- const sc::fifo_scheduler<>::processor_handle processor6 =
- scheduler.create_processor< FifoSchedulerTest >( 1, 2, 3, 4, 5, 6 );
- Check( scheduler, processor6, 123456 );
+ Check( scheduler, scheduler.create_processor< FifoSchedulerTest >(), 0 );
+
+ Check(
+ scheduler, scheduler.create_processor< FifoSchedulerTest >( 1 ), 1 );
+
+ Check(
+ scheduler,
+ scheduler.create_processor< FifoSchedulerTest >(
+ boost::cref( refArg1 ) ),
+ 6 );
+
+ Check(
+ scheduler,
+ scheduler.create_processor< FifoSchedulerTest >( 1, 2 ),
+ 12 );
+
+ Check(
+ scheduler,
+ scheduler.create_processor< FifoSchedulerTest >(
+ boost::cref( refArg1 ), boost::cref( refArg2 ) ),
+ 65 );
+
+ Check(
+ scheduler,
+ scheduler.create_processor< FifoSchedulerTest >( 1, 2, 3 ),
+ 123 );
+
+ Check(
+ scheduler,
+ scheduler.create_processor< FifoSchedulerTest >(
+ boost::cref( refArg1 ), boost::cref( refArg2 ),
+ boost::cref( refArg3 ) ),
+ 654 );
+
+ Check(
+ scheduler,
+ scheduler.create_processor< FifoSchedulerTest >( 1, 2, 3, 4 ),
+ 1234 );
+
+ Check(
+ scheduler,
+ scheduler.create_processor< FifoSchedulerTest >(
+ boost::cref( refArg1 ), boost::cref( refArg2 ),
+ boost::cref( refArg3 ), boost::cref( refArg4 ) ),
+ 6543 );
+
+ Check(
+ scheduler,
+ scheduler.create_processor< FifoSchedulerTest >( 1, 2, 3, 4, 5 ),
+ 12345 );
+
+ Check(
+ scheduler,
+ scheduler.create_processor< FifoSchedulerTest >(
+ boost::cref( refArg1 ), boost::cref( refArg2 ),
+ boost::cref( refArg3 ), boost::cref( refArg4 ),
+ boost::cref( refArg5 ) ),
+ 65432 );
+
+ Check(
+ scheduler,
+ scheduler.create_processor< FifoSchedulerTest >( 1, 2, 3, 4, 5, 6 ),
+ 123456 );
+
+ Check(
+ scheduler,
+ scheduler.create_processor< FifoSchedulerTest >(
+ boost::cref( refArg1 ), boost::cref( refArg2 ),
+ boost::cref( refArg3 ), boost::cref( refArg4 ),
+ boost::cref( refArg5 ), boost::cref( refArg6 ) ),
+ 654321 );
 
     RunScheduler( scheduler, 0UL );
     bool workItem1Processed = 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