Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r58345 - sandbox/fiber/libs/fiber/examples
From: oliver.kowalke_at_[hidden]
Date: 2009-12-13 07:03:11


Author: olli
Date: 2009-12-13 07:03:11 EST (Sun, 13 Dec 2009)
New Revision: 58345
URL: http://svn.boost.org/trac/boost/changeset/58345

Log:
- future test

Text files modified:
   sandbox/fiber/libs/fiber/examples/future.cpp | 39 ++++++++++++++++++++++++++++++++++++++-
   1 files changed, 38 insertions(+), 1 deletions(-)

Modified: sandbox/fiber/libs/fiber/examples/future.cpp
==============================================================================
--- sandbox/fiber/libs/fiber/examples/future.cpp (original)
+++ sandbox/fiber/libs/fiber/examples/future.cpp 2009-12-13 07:03:11 EST (Sun, 13 Dec 2009)
@@ -10,6 +10,43 @@
 #include <boost/fiber.hpp>
 #include <boost/fiber/spin/future.hpp>
 
+class callable
+{
+private:
+ struct impl
+ {
+ virtual ~impl() {}
+
+ virtual void exec() = 0;
+ };
+
+ template< typename T >
+ class timpl : public impl
+ {
+ private:
+ boost::fibers::spin::packaged_task< T > pt_;
+
+ public:
+ timpl( boost::fibers::spin::packaged_task< T > & pt) :
+ pt_( boost::move( pt) )
+ {}
+
+ void exec()
+ { pt_(); }
+ };
+
+ boost::shared_ptr< impl > impl_;
+
+public:
+ template< typename T >
+ callable( boost::fibers::spin::packaged_task< T > & pt) :
+ impl_( new timpl< T >( pt) )
+ {}
+
+ void operator()()
+ { impl_->exec(); }
+};
+
 inline
 std::string helloworld_fn()
 { return "Hello World"; }
@@ -22,7 +59,7 @@
 
                 boost::fibers::spin::packaged_task< std::string > pt( helloworld_fn);
                 boost::fibers::spin::unique_future< std::string > fu = pt.get_future();
- sched.make_fiber( boost::move( pt) );
+ sched.make_fiber( callable( pt) );
 
                 for (;;)
                 {


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