Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r52528 - in sandbox/task/boost: . task
From: oliver.kowalke_at_[hidden]
Date: 2009-04-21 15:37:01


Author: olli
Date: 2009-04-21 15:37:00 EDT (Tue, 21 Apr 2009)
New Revision: 52528
URL: http://svn.boost.org/trac/boost/changeset/52528

Log:
* id for task added

Added:
   sandbox/task/boost/task/id.hpp (contents, props changed)
Text files modified:
   sandbox/task/boost/task.hpp | 1 +
   sandbox/task/boost/task/handle.hpp | 35 +++++++++++++++++++++++++++++------
   sandbox/task/boost/task/task.hpp | 21 +++++++++++----------
   3 files changed, 41 insertions(+), 16 deletions(-)

Modified: sandbox/task/boost/task.hpp
==============================================================================
--- sandbox/task/boost/task.hpp (original)
+++ sandbox/task/boost/task.hpp 2009-04-21 15:37:00 EDT (Tue, 21 Apr 2009)
@@ -12,6 +12,7 @@
 #include <boost/task/exceptions.hpp>
 #include <boost/task/fifo.hpp>
 #include <boost/task/handle.hpp>
+#include <boost/task/id.hpp>
 #include <boost/task/info.hpp>
 #include <boost/task/launch.hpp>
 #include <boost/task/lifo.hpp>

Modified: sandbox/task/boost/task/handle.hpp
==============================================================================
--- sandbox/task/boost/task/handle.hpp (original)
+++ sandbox/task/boost/task/handle.hpp 2009-04-21 15:37:00 EDT (Tue, 21 Apr 2009)
@@ -13,6 +13,7 @@
 #include <boost/task/detail/interrupter.hpp>
 #include <boost/task/future.hpp>
 #include <boost/task/exceptions.hpp>
+#include <boost/task/id.hpp>
 
 namespace boost { namespace task
 {
@@ -48,16 +49,26 @@
 
         shared_future< R > fut_;
         detail::interrupter intr_;
+ id id_;
 
- handle( shared_future< R > const& fut, detail::interrupter const& intr)
- : fut_( fut), intr_( intr)
+ handle(
+ shared_future< R > const& fut,
+ detail::interrupter const& intr,
+ id const& id__)
+ :
+ fut_( fut),
+ intr_( intr),
+ id_( id__)
         {}
 
 public:
         handle()
- : fut_(), intr_()
+ : fut_(), intr_(), id_()
         {}
 
+ const id get_id() const
+ { return id_; }
+
         void interrupt()
         { intr_.interrupt(); }
 
@@ -105,6 +116,7 @@
         {
                 fut_.swap( other.fut_);
                 intr_.swap( other.intr_);
+ id_.swap( other.id_);
         }
 };
 
@@ -137,16 +149,27 @@
 
         shared_future< void > fut_;
         detail::interrupter intr_;
+ id id_;
 
- handle( shared_future< void > const& fut, detail::interrupter const& intr)
- : fut_( fut), intr_( intr)
+ handle(
+ shared_future< void > const& fut,
+ detail::interrupter const& intr,
+ id const& id__)
+ :
+ fut_( fut),
+ intr_( intr),
+ id_( id__)
         {}
 
+
 public:
         handle()
- : fut_(), intr_()
+ : fut_(), intr_(), id_()
         {}
 
+ const id get_id() const
+ { return id_; }
+
         void interrupt()
         { intr_.interrupt(); }
 

Added: sandbox/task/boost/task/id.hpp
==============================================================================
--- (empty file)
+++ sandbox/task/boost/task/id.hpp 2009-04-21 15:37:00 EDT (Tue, 21 Apr 2009)
@@ -0,0 +1,64 @@
+
+// Copyright Oliver Kowalke 2009.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_TASK_ID_H
+#define BOOST_TASK_ID_H
+
+#include <iostream>
+#include <string>
+
+namespace boost { namespace task
+{
+template< typename R >
+class task;
+
+class id
+{
+private:
+ template< typename R >
+ friend class task;
+
+ std::string id_;
+
+ id( std::string const& id__)
+ : id_( id__)
+ {}
+
+public:
+ id()
+ : id_("{not-any-task}")
+ {}
+
+ bool operator==( id const& other) const
+ { return id_ == other.id_; }
+
+ bool operator!=( id const& other) const
+ { return id_ != other.id_; }
+
+ bool operator<( id const& other) const
+ { return id_ < other.id_; }
+
+ bool operator>( id const& other) const
+ { return id_ > other.id_; }
+
+ bool operator<=( id const& other) const
+ { return id_ <= other.id_; }
+
+ bool operator>=( id const& other) const
+ { return id_ >= other.id_; }
+
+ template< typename charT, typename traitsT >
+ friend std::basic_ostream< charT, traitsT > &
+ operator<<( std::basic_ostream< charT, traitsT > & os, id const& r)
+ { return os << r.id_; }
+
+ void swap( id & other)
+ { id_.swap( other.id_); }
+};
+} }
+
+#endif // BOOST_TASK_ID_H
+

Modified: sandbox/task/boost/task/task.hpp
==============================================================================
--- sandbox/task/boost/task/task.hpp (original)
+++ sandbox/task/boost/task/task.hpp 2009-04-21 15:37:00 EDT (Tue, 21 Apr 2009)
@@ -11,8 +11,10 @@
 #include <ios>
 #include <new>
 #include <stdexcept>
+#include <string>
 #include <typeinfo>
 
+#include <boost/lexical_cast.hpp>
 #include <boost/preprocessor/repetition.hpp>
 #include <boost/thread.hpp>
 #include <boost/thread/thread_time.hpp>
@@ -22,6 +24,7 @@
 #include <boost/task/future.hpp>
 #include <boost/task/exceptions.hpp>
 #include <boost/task/handle.hpp>
+#include <boost/task/id.hpp>
 
 namespace boost { namespace task
 {
@@ -115,17 +118,16 @@
         shared_ptr< impl > impl_;
 
 public:
- task()
- : impl_()
- {}
-
         template< typename Fn >
         task( Fn const& fn)
         : impl_( new impl_wrapper< Fn >( fn) )
         {}
 
+ const id get_id() const
+ { return id( lexical_cast< std::string >( impl_.get() ) ); }
+
         const handle< R > get_handle()
- { return handle< R >( impl_->fut, impl_->intr); }
+ { return handle< R >( impl_->fut, impl_->intr, get_id() ); }
 
         void swap( task< R > & other) // throw()
         { impl_.swap( other.impl_); }
@@ -223,17 +225,16 @@
         shared_ptr< impl > impl_;
 
 public:
- task()
- : impl_()
- {}
-
         template< typename Fn >
         task( Fn const& fn)
         : impl_( new impl_wrapper< Fn >( fn) )
         {}
 
+ const id get_id() const
+ { return id( lexical_cast< std::string >( impl_.get() ) ); }
+
         const handle< void > get_handle()
- { return handle< void >( impl_->fut, impl_->intr); }
+ { return handle< void >( impl_->fut, impl_->intr, get_id() ); }
 
         void swap( task< void > & other) // throw()
         { impl_.swap( other.impl_); }


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