$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r64744 - sandbox/chrono/boost/chrono
From: vicente.botet_at_[hidden]
Date: 2010-08-11 13:19:55
Author: viboes
Date: 2010-08-11 13:19:33 EDT (Wed, 11 Aug 2010)
New Revision: 64744
URL: http://svn.boost.org/trac/boost/changeset/64744
Log:
* uniform both files
Text files modified: 
   sandbox/chrono/boost/chrono/stopwatch.hpp             |    57 +++++++++++++++++++++++---------------- 
   sandbox/chrono/boost/chrono/stopwatch_accumulator.hpp |    39 +++++++++++++++++++-------              
   2 files changed, 61 insertions(+), 35 deletions(-)
Modified: sandbox/chrono/boost/chrono/stopwatch.hpp
==============================================================================
--- sandbox/chrono/boost/chrono/stopwatch.hpp	(original)
+++ sandbox/chrono/boost/chrono/stopwatch.hpp	2010-08-11 13:19:33 EDT (Wed, 11 Aug 2010)
@@ -13,9 +13,9 @@
 #include <utility>
 #include <boost/chrono/chrono.hpp>
 #include <boost/chrono/stopwatch_scoped.hpp>
-#include <boost/chrono/stopwatch_formatter.hpp>
 #include <boost/chrono/stopwatch_reporter.hpp>
 #include <boost/system/error_code.hpp>
+#include <boost/chrono/stopwatch_formatter.hpp>
 
 #include <boost/config/abi_prefix.hpp> // must be the last #include
 
@@ -54,6 +54,7 @@
 
     struct dont_start_t{};
     static const dont_start_t dont_start = {};
+//--------------------------------------------------------------------------------------//
     template <class Clock>
     class stopwatch
     {
@@ -65,24 +66,45 @@
         typedef typename Clock::period      period;
 
         explicit stopwatch( system::error_code & ec = system::throws  )
-        : running_(false), suspended_(false), start_(), level_(0), partial_(duration::zero()), suspend_level_(0)
+        : running_(false), suspended_(false),
+          start_(duration::zero()), level_(0), partial_(duration::zero()), suspend_level_(0)
         {
             start(ec);
         }
 
         explicit stopwatch( const dont_start_t& t )
-        : running_(false), suspended_(false), start_(), level_(0), partial_(duration::zero()), suspend_level_(0)
+        : running_(false), suspended_(false),
+          start_(duration::zero()), level_(0), partial_(duration::zero()), suspend_level_(0)
         { }
 
-        time_point start( system::error_code & ec = system::throws ) {
+//--------------------------------------------------------------------------------------//
+        std::pair<duration, time_point> restart( system::error_code & ec = system::throws ) {
+            duration frozen;
+            time_point tmp=clock::now( ec );
+            if (ec) return time_point();
+            if (running_&&(--level_==0)) {
+                partial_ += tmp - start_;
+                frozen = partial_;
+                partial_=duration::zero();
+            } else {
+                frozen = duration::zero();
+                running_=true;
+            }
+            start_=tmp;
             ++level_;
+            return std::make_pair(frozen, start_);
+        }
+
+        time_point start( system::error_code & ec = system::throws ) {
             if (!running_) {
                 time_point tmp = clock::now( ec );
                 if (ec) return time_point();
                 start_ = tmp;
-                running_=true;
+                ++level_;
+                running_ = true;
                 return start_;
             } else {
+                ++level_;
                 ec.clear();
                 return time_point();
             }
@@ -103,23 +125,6 @@
             }
         }
 
-        std::pair<duration, time_point> restart( system::error_code & ec = system::throws ) {
-            duration frozen;
-            time_point tmp=clock::now( ec );
-            if (ec) return time_point();
-            if (running_&&(--level_==0)) {
-                partial_ += tmp - start_;
-                frozen = partial_;
-                partial_=duration::zero();
-            } else {
-                frozen = duration::zero();
-                running_=true;
-            }
-            start_=tmp;
-            ++level_;
-            return std::make_pair(frozen, start_);
-        }
-
         duration suspend( system::error_code & ec = system::throws ) {
             if (running_) {
                 ++suspend_level_;
@@ -134,6 +139,7 @@
                     return duration::zero();
                 }
             } else {
+                ec.clear();
                 return duration::zero();
             }
         }
@@ -164,9 +170,12 @@
         }
 
         void reset( system::error_code & ec = system::throws ) {
-            start_ = time_point();
-            level_=0;
             running_=false;
+            suspended_=false;
+            partial_ = duration::zero();
+            start_  = time_point(duration::zero());
+            level_=0;
+            suspend_level_=0;
             ec.clear();
         }
 
Modified: sandbox/chrono/boost/chrono/stopwatch_accumulator.hpp
==============================================================================
--- sandbox/chrono/boost/chrono/stopwatch_accumulator.hpp	(original)
+++ sandbox/chrono/boost/chrono/stopwatch_accumulator.hpp	2010-08-11 13:19:33 EDT (Wed, 11 Aug 2010)
@@ -15,8 +15,8 @@
 #include <boost/chrono/chrono.hpp>
 #include <boost/chrono/stopwatch_scoped.hpp>
 #include <boost/chrono/stopwatch_reporter.hpp>
-#include <boost/chrono/stopwatch_accumulator_formatter.hpp>
 #include <boost/system/error_code.hpp>
+#include <boost/chrono/stopwatch_accumulator_formatter.hpp>
 #include <boost/accumulators/framework/accumulator_set.hpp>
 #include <boost/accumulators/statistics/sum.hpp>
 #include <boost/accumulators/statistics/min.hpp>
@@ -76,15 +76,18 @@
         typedef Clock                       clock;
         typedef typename Clock::duration    duration;
         typedef typename Clock::time_point  time_point;
+        typedef typename Clock::rep         rep;
+        typedef typename Clock::period      period;
         typedef Accumulator accumulator;
 
         stopwatch_accumulator( )
-        : running_(false), suspended_(false), accumulated_(),
-          partial_(), start_(duration::zero()), level_(0), suspend_level_(0)
-          , construction_(clock::now( ))
+        : running_(false), suspended_(false),
+          start_(duration::zero()), level_(0), partial_(duration::zero()), suspend_level_(0)
+          , accumulated_(), construction_(clock::now( ))
         {}
 
-        std::pair<duration, time_point>  restart( system::error_code & ec = system::throws ) {
+//--------------------------------------------------------------------------------------//
+        std::pair<duration, time_point> restart( system::error_code & ec = system::throws ) {
             time_point tmp=clock::now( ec );
             if (ec) return time_point();
             if (running_&&(--level_==0)) {
@@ -107,8 +110,9 @@
                 ++level_;
                 running_ = true;
                 return start_;
-            }  else {
+            } else {
                 ++level_;
+                ec.clear();
                 return time_point();
             }
         }
@@ -123,12 +127,14 @@
                     partial_=duration::zero();
                     --level_;
                     running_=false;
-                    return duration(accumulators::extract::sum(accumulated_));
+                    return duration(accumulators::sum(accumulated_));
                 } else {
                     --level_;
+                    ec.clear();
                     return duration::zero();
                 }
             } else {
+                ec.clear();
                 return duration::zero();
             }
         }
@@ -143,12 +149,15 @@
                     suspended_=true;
                     return duration(accumulators::sum(accumulated_));
                 } else {
+                    ec.clear();
                     return duration::zero();
                 }
             } else {
+                ec.clear();
                 return duration::zero();
             }
         }
+
         time_point resume( system::error_code & ec = system::throws ) {
             if (suspended_&&(--suspend_level_==0)) {
                 time_point tmp = clock::now( ec );
@@ -157,6 +166,7 @@
                 suspended_=false;
                 return start_;
             } else {
+                ec.clear();
                 return time_point();
             }
         }
@@ -175,16 +185,23 @@
             }
         }
 
+        time_point now( system::error_code & ec = system::throws )
+        {
+            return time_point(elapsed( ec ));
+        }
+
         void reset( system::error_code & ec = system::throws ) {
             construction_=clock::now( ec );
+            accumulated_ = accumulator();
             running_=false;
             suspended_=false;
-            accumulated_ = accumulator();
-            partial_=duration::zero();
+            partial_ = duration::zero();
             start_  = time_point(duration::zero());
             level_=0;
             suspend_level_=0;
+            ec.clear();
         }
+        
         accumulator& accumulated( ) { return accumulated_; }
         duration lifetime( system::error_code & ec = system::throws ) {
             return  clock::now( ec ) - construction_;
@@ -202,11 +219,11 @@
     private:
         bool running_;
         bool suspended_;
-        accumulator accumulated_;
-        duration partial_;
         time_point start_;
         std::size_t level_;
+        duration partial_;
         std::size_t suspend_level_;
+        accumulator accumulated_;
         time_point construction_;
     };