mirror of
https://github.com/boostorg/test.git
synced 2026-01-23 18:12:12 +00:00
107 lines
6.1 KiB
HTML
107 lines
6.1 KiB
HTML
<HTML>
|
|
<HEAD>
|
|
<TITLE>boost::execution_monitor</TITLE>
|
|
<LINK rel="stylesheet" type="text/css" href="../../style/btl.css" media="screen">
|
|
<LINK rel="stylesheet" type="text/css" href="../../style/btl-print.css" media="print">
|
|
<META http-equiv="Content-Language" content="en-us">
|
|
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
</HEAD>
|
|
<BODY>
|
|
<DIV class="header"> <A href="../../index.html">Boost.Test</A> > <A href="../index.html">Components</A> > <A href="index.html">The
|
|
Execution Monitor</A> > <SPAN class="current_article">boost::execution_monitor</SPAN> </DIV>
|
|
<DIV class="body"> <IMG src="../../btl1.gif" width="252" height="43" alt="Boost Test logo">
|
|
<H1 class="subtitle">boost::execution_monitor</H1>
|
|
<P class="first-line-indented">boost::execution_monitor uniformly detects and
|
|
reports the occurrence of several types of signals and exceptions, reducing
|
|
various errors to a uniform <A href="execution_exception.html">boost::execution_exception</A> that
|
|
is returned to a caller.</P>
|
|
<PRE class="code"><SPAN class="reserv-word">class</SPAN> <SPAN class="new-term">execution_monitor</SPAN> {
|
|
<SPAN class="reserv-word">public</SPAN>:
|
|
<SPAN class="cpp-type">int</SPAN> execute( unit_test::callback0<<SPAN class="cpp-type">int</SPAN>> const& F, <SPAN class="cpp-type">bool</SPAN> catch_system_errors = true, <SPAN class="cpp-type">int</SPAN> timeout = <SPAN class="literal">0</SPAN> );
|
|
|
|
<SPAN class="reserv-word">template</SPAN><<SPAN class="reserv-word">typename</SPAN> Exception, <SPAN class="reserv-word">typename</SPAN> ExceptionTranslator>
|
|
<SPAN class="cpp-type">void</SPAN> register_exception_translator( ExceptionTranslator <SPAN class="reserv-word">const</SPAN>& tr, boost::type<Exception>* = <SPAN class="literal">0</SPAN> );
|
|
}; <SPAN class="comment">// exception monitor</SPAN>
|
|
</PRE>
|
|
<H3>execution_monitor::execute( unit_test::callback0<int> const& F,
|
|
bool catch_system_errors, int timeout )</H3>
|
|
<P class="first-line-indented">Effects:</P>
|
|
<P class="indented"> Calls the zero arity function <EM>F</EM> inside a try/catch
|
|
block which may also include other unspecified platform dependent error detection
|
|
code. Throws <A href="execution_exception.html">boost::execution_exception</A> on
|
|
an uncaught C++ exception, a timeout alarm and, a hardware or software signal,
|
|
trap, or other exception. execution_monitor::execute() <SPAN style="text-decoration: underline">doesn't</SPAN> consider
|
|
it an error for the function F to return a non-zero value. </P>
|
|
<P class="first-line-indented">Arguments:</P>
|
|
<P class="indented">
|
|
<TABLE border="0">
|
|
<TR>
|
|
<TH align="left" valign="top" scope="row">F</TH>
|
|
<TD valign="top">-</TD>
|
|
<TD>zero arity function to be monitored </TD>
|
|
</TR>
|
|
<TR>
|
|
<TH align="left" valign="top" scope="row"><A name="catch_system_errors">catch_system_exception</A></TH>
|
|
<TD valign="top">-</TD>
|
|
<TD>boolean flag that indicates whether system level errors/signals needs
|
|
to be traped. If this flag is false program will crash if system level
|
|
error occur. Default value is true.</TD>
|
|
</TR>
|
|
<TR>
|
|
<TH align="left" valign="top" scope="row">timeout</TH>
|
|
<TD valign="top">-</TD>
|
|
<TD>a time-out value that specifies seconds that elapse before a timeout
|
|
error occurs. Note though, that in current implementation timeout support
|
|
is limited and may be ignored on some platforms. By default there
|
|
is no timeout for the monitored call.</TD>
|
|
</TR>
|
|
</TABLE>
|
|
</P>
|
|
<P class="first-line-indented">Returns:</P>
|
|
<P class="indented"> The integer value returned by the function F or boost::exit_exception_failure
|
|
in the case of caught exception.</P>
|
|
<H3>execution_monitor::<SPAN class="code">register_exception_translator<Exception></SPAN><A name="register_exception_translator"></A>(
|
|
ExceptionTranslator const& tr )</H3>
|
|
<P class="first-line-indented"> Effects:</P>
|
|
<P class="indented">Registers translator function <EM>tr</EM> for an exception
|
|
of type <EM>Exception</EM>.
|
|
Translators gets chained, so you can register as many as you want. The
|
|
<EM>Exception</EM> type
|
|
needs to be specified explicitly as the member function template argument.
|
|
The translator function gets called when an exception of type <EM>Exception</EM> is
|
|
thrown from within the monitored function. The translator recieves
|
|
a thrown exception object as its first argument. Result value of translator
|
|
is ignored and no exception is reported if this function exits normally.
|
|
But you could always rethrow the exception or throw a different one.</P>
|
|
<P class="first-line-indented">Arguments:</P>
|
|
<P class="indented">
|
|
<TABLE border="0">
|
|
<TR>
|
|
<TH align="left" valign="top" scope="row">tr</TH>
|
|
<TD valign="top">-</TD>
|
|
<TD>translator function for an exception <SPAN class="indented"><EM>Exception</EM></SPAN>. <SPAN class="indented">Translator
|
|
type <EM>ExceptionTranslator</EM> should
|
|
present single function:<BR>
|
|
<BR>
|
|
<EM>arbitrary-type </EM>operator()(<EM> Exception</EM> const& ) const</SPAN></TD>
|
|
</TR>
|
|
</TABLE></P>
|
|
<P class="first-line-indented">Example:</P>
|
|
<PRE class="code"><SPAN class="cpp-type">void</SPAN> translate_my_exception1( my_exception1 const& ) { <SPAN class="comment">/* ... */</SPAN> } <BR>
|
|
the_monitor.register_exception_translator<my_exception1>( translate_my_exception1 );</PRE>
|
|
</DIV>
|
|
<DIV class="footer">
|
|
<DIV class="footer-body">
|
|
<P> © <A name="Copyright">Copyright</A> <A href="mailto:boost-test%20at%20emailaccount%20dot%20com%20%28please%20unobscure%29">Gennadiy
|
|
Rozental</A> 2001-2006. <BR>
|
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
file <A href="../../../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A> or copy
|
|
at <A href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</A>)</P>
|
|
<P>Revised:
|
|
<!-- #BeginDate format:Sw1 -->4 February, 2006<!-- #EndDate -->
|
|
</P>
|
|
</DIV>
|
|
</DIV>
|
|
</BODY>
|
|
</HTML>
|