本文整理汇总了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));
}
示例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);
}
}
}
}
示例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();
}
}
}
}
示例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
}
示例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();
}
}
}
}
示例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();
}
}
}
示例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);
}
}
}
}
示例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();
}
}
}
示例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();
}
}
}
}