File: execution_monitor.html

package info (click to toggle)
boost 1.34.1-14
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 116,412 kB
  • ctags: 259,566
  • sloc: cpp: 642,395; xml: 56,450; python: 17,612; ansic: 14,520; sh: 2,265; yacc: 858; perl: 481; makefile: 478; lex: 94; sql: 74; csh: 6
file content (105 lines) | stat: -rw-r--r-- 6,256 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<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> 
   <TABLE class="indented" 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 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>
  <TABLE border="0" class="indented">
    <TR>
      <TH align="left" valign="top" scope="row">tr</TH>
      <TD valign="top">-</TD>
      <TD>translator function for an exception <EM>Exception</EM>. Translator
          type <EM>ExceptionTranslator</EM> should
          present single function:<BR>
        <BR>        <EM>arbitrary-type </EM>operator()(<EM> Exception</EM> const&amp; )
      const</TD>
    </TR>
  </TABLE>
  <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 -->28 February, 2006<!-- #EndDate --> 
    </P> 
  </DIV> 
</DIV> 
</BODY>
</HTML>