2
0
mirror of https://github.com/boostorg/test.git synced 2026-01-23 18:12:12 +00:00
Files
test/doc/components/execution_monitor/execution_monitor.html
Gennadiy Rozental 06e7e97366 in progress
[SVN r33093]
2006-02-23 19:29:10 +00:00

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> &gt; <A href="../index.html">Components</A> &gt; <A href="index.html">The
Execution Monitor</A> &gt; <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&lt;<SPAN class="cpp-type">int</SPAN>&gt; const&amp; 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>&lt;<SPAN class="reserv-word">typename</SPAN> Exception, <SPAN class="reserv-word">typename</SPAN> ExceptionTranslator&gt;
<SPAN class="cpp-type">void</SPAN> register_exception_translator( ExceptionTranslator <SPAN class="reserv-word">const</SPAN>&amp; tr, boost::type&lt;Exception&gt;* = <SPAN class="literal">0</SPAN> );
}; <SPAN class="comment">// exception monitor</SPAN>
</PRE>
<H3>execution_monitor::execute( unit_test::callback0&lt;int&gt; const&amp; 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&lt;Exception&gt;</SPAN><A name="register_exception_translator"></A>(
ExceptionTranslator const&amp; 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&amp; ) 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&amp; ) { <SPAN class="comment">/* ... */</SPAN> } <BR>
the_monitor.register_exception_translator&lt;my_exception1&gt;( translate_my_exception1 );</PRE>
</DIV>
<DIV class="footer">
<DIV class="footer-body">
<P> &copy; <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>