当前位置: 首页>>代码示例>>C++>>正文


C++ error_code::clear方法代码示例

本文整理汇总了C++中system::error_code::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ error_code::clear方法的具体用法?C++ error_code::clear怎么用?C++ error_code::clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在system::error_code的用法示例。


在下文中一共展示了error_code::clear方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: now

  steady_clock::time_point steady_clock::now(system::error_code & ec)
  {
    timespec ts;
    if ( ::clock_gettime( CLOCK_MONOTONIC, &ts ) )
    {
        if (BOOST_CHRONO_IS_THROWS(ec))
        {
            boost::throw_exception(
                    system::system_error( 
                            errno, 
                            BOOST_CHRONO_SYSTEM_CATEGORY, 
                            "chrono::steady_clock" ));
        }
        else
        {
            ec.assign( errno, BOOST_CHRONO_SYSTEM_CATEGORY );
            return time_point();
        }
    }

    if (!BOOST_CHRONO_IS_THROWS(ec)) 
    {
        ec.clear();
    }
    return time_point(duration(
      static_cast<steady_clock::rep>( ts.tv_sec ) * 1000000000 + ts.tv_nsec));
  }
开发者ID:AsgeirSH,项目名称:Client,代码行数:27,代码来源:chrono.hpp

示例2: now

    void process_clock::now( process_times & times_, system::error_code & ec ) {

        tms tm;
        clock_t c = ::times( &tm );
        if ( c == clock_t(-1) ) // error
        {
            if (BOOST_CHRONO_IS_THROWS(ec))
            {
                boost::throw_exception(
                        system::system_error( 
                                errno, 
                                BOOST_CHRONO_SYSTEM_CATEGORY, 
                                "chrono::process_clock" ));
            }
            else
            {
                ec.assign( errno, BOOST_CHRONO_SYSTEM_CATEGORY );
                times_.real = times_.system = times_.user = nanoseconds(-1);
            }
        }
        else
        {
            times_.real = microseconds(c);
            times_.system = microseconds(tm.tms_stime + tm.tms_cstime);
            times_.user = microseconds(tm.tms_utime + tm.tms_cutime);
            if ( chrono_detail::tick_factor() != -1 )
            {
                if (!BOOST_CHRONO_IS_THROWS(ec)) 
                {
                  ec.clear();
                }
                times_.real *= chrono_detail::tick_factor();
                times_.user *= chrono_detail::tick_factor();
                times_.system *= chrono_detail::tick_factor();
            }
            else
            {
                if (BOOST_CHRONO_IS_THROWS(ec))
                {
                    boost::throw_exception(
                            system::system_error( 
                                    errno, 
                                    BOOST_CHRONO_SYSTEM_CATEGORY, 
                                    "chrono::process_clock" ));
                }
                else
                {
                    ec.assign( errno, BOOST_CHRONO_SYSTEM_CATEGORY );
                    times_.real = times_.user = times_.system = nanoseconds(-1);
                }
            }
        }

    }
开发者ID:AsgeirSH,项目名称:Client,代码行数:54,代码来源:process_clock.hpp

示例3: now

process_real_cpu_clock::time_point process_real_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))
        {
            boost::throw_exception(
                    system::system_error( 
                            errno, 
                            BOOST_CHRONO_SYSTEM_CATEGORY, 
                            "chrono::process_real_cpu_clock" ));
        }
        else
        {
            ec.assign( errno, BOOST_CHRONO_SYSTEM_CATEGORY );
            return time_point();
        }
    }
    else
    {
        if ( chrono_detail::tick_factor() != -1 )
        {
            if (!BOOST_CHRONO_IS_THROWS(ec)) 
            {
                ec.clear();
            }
            return time_point(
                    microseconds(c)*chrono_detail::tick_factor());
        }
        else
        {
            if (BOOST_CHRONO_IS_THROWS(ec))
            {
                boost::throw_exception(
                        system::system_error( 
                                errno, 
                                BOOST_CHRONO_SYSTEM_CATEGORY, 
                                "chrono::process_real_cpu_clock" ));
            }
            else
            {
                ec.assign( errno, BOOST_CHRONO_SYSTEM_CATEGORY );
                return time_point();
            }
        }
    }
}
开发者ID:AVCProject,项目名称:AVC,代码行数:51,代码来源:process_cpu_clocks.hpp

示例4: now

process_cpu_clock::time_point process_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;

  #ifdef UNDER_CE
  // Windows CE does not support GetProcessTimes
    assert( 0 && "GetProcessTimes not supported under Windows CE" );
  return time_point();
  #else
    if ( boost::detail::win32::GetProcessTimes(
            boost::detail::win32::GetCurrentProcess(), &creation, &exit,
            &system_time, &user_time ) )
    {
        if (!BOOST_CHRONO_IS_THROWS(ec)) 
        {
            ec.clear();
        }
        time_point::rep r(
                steady_clock::now().time_since_epoch().count(), 
                ((static_cast<process_user_cpu_clock::rep>(user_time.dwHighDateTime) << 32)
                        | user_time.dwLowDateTime
                ) * 100, 
                ((static_cast<process_system_cpu_clock::rep>(system_time.dwHighDateTime) << 32)
                        | system_time.dwLowDateTime
                ) * 100 
        );
        return time_point(duration(r));
    }
    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_cpu_clock" ));
        } 
        else 
        {
            ec.assign( cause, BOOST_CHRONO_SYSTEM_CATEGORY );
            return time_point();
        }
    }
  #endif

}
开发者ID:AVCProject,项目名称:AVC,代码行数:51,代码来源:process_cpu_clocks.hpp

示例5: now

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))
        {
            boost::throw_exception(
                    system::system_error(
                            errno,
                            ::boost::system::system_category(),
                            "chrono::process_system_cpu_clock" ));
        }
        else
        {
            ec.assign( errno, ::boost::system::system_category() );
            return time_point();
        }
    }
    else
    {
        if ( chrono_detail::tick_factor() != -1 )
        {
            if (!::boost::chrono::is_throws(ec))
            {
                ec.clear();
            }
            return time_point(
                nanoseconds((tm.tms_stime + tm.tms_cstime)*chrono_detail::tick_factor()));
        }
        else
        {
            if (::boost::chrono::is_throws(ec))
            {
                boost::throw_exception(
                        system::system_error(
                                errno,
                                ::boost::system::system_category(),
                                "chrono::process_system_cpu_clock" ));
            }
            else
            {
                ec.assign( errno, ::boost::system::system_category() );
                return time_point();
            }
        }
    }
}
开发者ID:betajippity,项目名称:Nuparu,代码行数:50,代码来源:process_cpu_clocks.hpp

示例6: now

process_cpu_clock::time_point process_cpu_clock::now(
        system::error_code & ec )
{

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

    if ( autoboost::detail::winapi::GetProcessTimes(
            autoboost::detail::winapi::GetCurrentProcess(), &creation, &exit,
            &system_time, &user_time ) )
    {
        if (!AUTOBOOST_CHRONO_IS_THROWS(ec))
        {
            ec.clear();
        }
        time_point::rep r(process_real_cpu_clock::now().time_since_epoch().count()
                            ,
                ((static_cast<process_user_cpu_clock::rep>(user_time.dwHighDateTime) << 32)
                        | user_time.dwLowDateTime
                ) * 100,
                ((static_cast<process_system_cpu_clock::rep>(system_time.dwHighDateTime) << 32)
                        | system_time.dwLowDateTime
                ) * 100
        );
        return time_point(duration(r));
    }
    else
    {
        autoboost::detail::winapi::DWORD_ cause = autoboost::detail::winapi::GetLastError();
        if (AUTOBOOST_CHRONO_IS_THROWS(ec))
        {
            autoboost::throw_exception(
                    system::system_error(
                            cause,
                            AUTOBOOST_CHRONO_SYSTEM_CATEGORY,
                            "chrono::process_cpu_clock" ));
        }
        else
        {
            ec.assign( cause, AUTOBOOST_CHRONO_SYSTEM_CATEGORY );
            return time_point();
        }
    }

}
开发者ID:c-zheng,项目名称:autowiring,代码行数:45,代码来源:process_cpu_clocks.hpp

示例7: report

    void run_timer::report( system::error_code & ec )
    {
      m_reported = true;
      if ( m_format.empty() ) m_format = chrono_detail::default_format();

      process_times times;
      elapsed( times, ec );
      if (ec) return;

      if ( BOOST_CHRONO_IS_THROWS(ec) )
      {
        chrono_detail::show_time( times, m_format.c_str(), m_places, m_os );
      }
      else // non-throwing
      {
        try
        {
          chrono_detail::show_time( times, m_format.c_str(), m_places, m_os );
          if (!BOOST_CHRONO_IS_THROWS(ec)) 
          {
            ec.clear();
          }
        }

        catch (...) // eat any exceptions
        {
          BOOST_ASSERT( 0 && "error reporting not fully implemented yet" );
          if (BOOST_CHRONO_IS_THROWS(ec))
          {
              boost::throw_exception(
                      system::system_error( 
                              errno, 
                              BOOST_CHRONO_SYSTEM_CATEGORY, 
                              "chrono::run_timer" ));
          } 
          else
          {
            ec.assign(system::errc::success, BOOST_CHRONO_SYSTEM_CATEGORY);
          }
          }
      }
    }
开发者ID:AVCProject,项目名称:AVC,代码行数:42,代码来源:run_timer.hpp

示例8: now

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();
        }
    }

}
开发者ID:AKinanS,项目名称:Server,代码行数:39,代码来源:process_cpu_clocks.hpp

示例9: now

 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))
     {
       pdalboost::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))
       {
         pdalboost::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();
       }
     }
   }
 }
开发者ID:AsherBond,项目名称:PDAL,代码行数:37,代码来源:process_cpu_clocks.hpp


注:本文中的system::error_code::clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。