コード例 #1
0
ファイル: process_cpu_clocks.hpp プロジェクト: AKinanS/Server
process_system_cpu_clock::time_point process_system_cpu_clock::now(
        system::error_code & ec)
{

    //  note that Windows uses 100 nanosecond ticks for FILETIME
    boost::detail::win32::FILETIME_ creation, exit, user_time, system_time;

    if ( boost::detail::win32::GetProcessTimes(
            boost::detail::win32::GetCurrentProcess(), &creation, &exit,
            &system_time, &user_time ) )
    {
        if (!BOOST_CHRONO_IS_THROWS(ec))
        {
            ec.clear();
        }
        return time_point(duration(
                ((static_cast<process_system_cpu_clock::rep>(system_time.dwHighDateTime) << 32)
                                    | system_time.dwLowDateTime) * 100
                ));
    }
    else
    {
        boost::detail::win32::DWORD_ cause = boost::detail::win32::GetLastError();
        if (BOOST_CHRONO_IS_THROWS(ec))
        {
            boost::throw_exception(
                    system::system_error(
                            cause,
                            BOOST_CHRONO_SYSTEM_CATEGORY,
                            "chrono::process_system_cpu_clock" ));
        }
        else
        {
            ec.assign( cause, BOOST_CHRONO_SYSTEM_CATEGORY );
            return time_point();
        }
    }

}
コード例 #2
0
ファイル: process_cpu_clocks.hpp プロジェクト: AsherBond/PDAL
    process_cpu_clock::time_point process_cpu_clock::now(system::error_code & ec)
    {

      tms tm;
      clock_t c = ::times(&tm);
      if (c == clock_t(-1)) // error
      {
        if (BOOST_CHRONO_IS_THROWS(ec))
        {
          pdalboost::throw_exception(system::system_error(errno, BOOST_CHRONO_SYSTEM_CATEGORY, "chrono::process_clock"));
        } else
        {
          ec.assign(errno, BOOST_CHRONO_SYSTEM_CATEGORY);
          return time_point();
        }
      } else
      {
        long factor = chrono_detail::tick_factor();
        if (factor != -1)
        {
          time_point::rep
              r(c * factor, (tm.tms_utime + tm.tms_cutime) * factor, (tm.tms_stime
                  + tm.tms_cstime) * factor);
          return time_point(duration(r));
        } else
        {
          if (BOOST_CHRONO_IS_THROWS(ec))
          {
            pdalboost::throw_exception(system::system_error(errno, BOOST_CHRONO_SYSTEM_CATEGORY, "chrono::process_clock"));
          } else
          {
            ec.assign(errno, BOOST_CHRONO_SYSTEM_CATEGORY);
            return time_point();
          }
        }
      }

    }
コード例 #3
0
ファイル: errored_clock.hpp プロジェクト: 0xDEC0DE8/mcsema
 // never throws and set ec
 static time_point  now(boost::system::error_code & ec) {
     if (BOOST_CHRONO_IS_THROWS(ec))
     {
         boost::throw_exception(
                 boost::system::system_error(
                         errno_,
                         BOOST_CHRONO_SYSTEM_CATEGORY,
                         "errored_clock"
                 )
         );
     }
     ec.assign( errno_, BOOST_CHRONO_SYSTEM_CATEGORY );
     return time_point();
 };
コード例 #4
0
ファイル: laps_stopwatch.hpp プロジェクト: LancelotGHX/Simula
      /**
       * Start the stopwatch.
       *
       * Effects: Assign the error code if any internal error occur while retrieving the current time.
       * Effects: Gives the elapsed time since start time to the LapCollector if no internal error occurs.
       *
       * Throws: Any exception that the LapCollector can Throw.
       *
       * Post-conditions: !is_running() if no error occur.
       */
      void stop(
          system::error_code & ec
          )
      {
        if (is_running())
        {
          time_point tmp = clock::now(ec);
          if (!BOOST_CHRONO_IS_THROWS(ec) && ec) return;

          laps_collector_.store(tmp - start_);
          start_ = time_point(duration::zero());
          running_ = false;
        }
      }
コード例 #5
0
ファイル: process_cpu_clocks.hpp プロジェクト: Iinvictus/mars
 process_system_cpu_clock::time_point process_system_cpu_clock::now(system::error_code & ec)
 {
   tms tm;
   clock_t c = ::times(&tm);
   if (c == clock_t(-1)) // error
   {
     if (BOOST_CHRONO_IS_THROWS(ec))
     {
       mars_boost::throw_exception(system::system_error(errno, BOOST_CHRONO_SYSTEM_CATEGORY, "chrono::process_system_cpu_clock"));
     } else
     {
       ec.assign(errno, BOOST_CHRONO_SYSTEM_CATEGORY);
       return time_point();
     }
   } else
   {
     long factor = chrono_detail::tick_factor();
     if (factor != -1)
     {
       if (!BOOST_CHRONO_IS_THROWS(ec))
       {
         ec.clear();
       }
       return time_point(nanoseconds((tm.tms_stime + tm.tms_cstime) * factor));
     } else
     {
       if (BOOST_CHRONO_IS_THROWS(ec))
       {
         mars_boost::throw_exception(system::system_error(errno, BOOST_CHRONO_SYSTEM_CATEGORY, "chrono::process_system_cpu_clock"));
       } else
       {
         ec.assign(errno, BOOST_CHRONO_SYSTEM_CATEGORY);
         return time_point();
       }
     }
   }
 }
コード例 #6
0
ファイル: laps_stopwatch.hpp プロジェクト: LancelotGHX/Simula
      /**
       * Elapsed time getter for the current lap.
       *
       * Effects: Assign the error code if any internal error occur while retrieving the current time.
       *
       * Returns: the elapsed time since the start if no internal error occur.
       *
       */
      duration elapsed_current_lap(
          system::error_code & ec
          ) const
      {
        if (is_running())
        {
            time_point tmp = clock::now(ec);
            if (!BOOST_CHRONO_IS_THROWS(ec) && ec) return duration::zero();

            return tmp - start_;
        } else
        {
          return duration::zero();
        }
      }
コード例 #7
0
ファイル: laps_stopwatch.hpp プロジェクト: LancelotGHX/Simula
      /**
       * Restart the stopwatch.
       *
       * Effects: Assign the error code if any internal error occur while retrieving the current time.
       * Effects: As if stop(); start() were called, but ensuring that the start time is the same as the stop time.
       *
       * Post-conditions: is_running() if no error occur.
       */
      void restart(
          system::error_code & ec
          )
      {
        time_point tmp = clock::now(ec);
        if (!BOOST_CHRONO_IS_THROWS(ec) && ec) return;

        if (is_running())
        {
          laps_collector_.store(tmp - start_);
        }
        else
        {
          running_ = true;
        }
        start_ = tmp;
      }