\hypertarget{orte__wait_8h}{\section{orte/runtime/orte\+\_\+wait.h File Reference}
\label{orte__wait_8h}\index{orte/runtime/orte\+\_\+wait.\+h@{orte/runtime/orte\+\_\+wait.\+h}}
}


Interface for waitpid / async notification of child death with the libevent runtime system.  


{\ttfamily \#include \char`\"{}orte\+\_\+config.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}opal/dss/dss.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}opal/util/output.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}opal/sys/atomic.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}opal/mca/event/event.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}orte/types.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}orte/mca/rml/rml\+\_\+types.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}opal/runtime/opal\+\_\+progress.\+h\char`\"{}}\\*
\subsection*{Data Structures}
\begin{DoxyCompactItemize}
\item 
struct \hyperlink{structorte__trigger__event__t}{orte\+\_\+trigger\+\_\+event\+\_\+t}
\item 
struct \hyperlink{structorte__message__event__t}{orte\+\_\+message\+\_\+event\+\_\+t}
\begin{DoxyCompactList}\small\item\em Setup an event to process a message. \end{DoxyCompactList}\item 
struct \hyperlink{structorte__notify__event__t}{orte\+\_\+notify\+\_\+event\+\_\+t}
\end{DoxyCompactItemize}
\subsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \hyperlink{orte__wait_8h_a1f38f222c63cfac9974311f0d6a6befa}{O\+R\+T\+E\+\_\+\+P\+R\+O\+G\+R\+E\+S\+S\+E\+D\+\_\+\+W\+A\+I\+T}(failed, counter, limit)
\begin{DoxyCompactList}\small\item\em In a number of places in the code, we need to wait for something to complete -\/ for example, waiting for all launched procs to report into the H\+N\+P. \end{DoxyCompactList}\item 
\#define {\bfseries O\+R\+T\+E\+\_\+\+M\+E\+S\+S\+A\+G\+E\+\_\+\+E\+V\+E\+N\+T\+\_\+\+D\+E\+L\+A\+Y}(delay, mev)
\item 
\#define {\bfseries O\+R\+T\+E\+\_\+\+M\+E\+S\+S\+A\+G\+E\+\_\+\+E\+V\+E\+N\+T}(sndr, buf, tg, cbfunc)
\item 
\#define {\bfseries O\+R\+T\+E\+\_\+\+N\+O\+T\+I\+F\+Y\+\_\+\+E\+V\+E\+N\+T}(cbfunc, data)
\item 
\#define \hyperlink{orte__wait_8h_a56bd663963b0bdb8a2843f25dd98a279}{O\+R\+T\+E\+\_\+\+D\+E\+T\+E\+C\+T\+\_\+\+T\+I\+M\+E\+O\+U\+T}(\hyperlink{structevent}{event}, n, deltat, maxwait, cbfunc)
\begin{DoxyCompactList}\small\item\em In a number of places within the code, we want to setup a timer to detect when some procedure failed to complete. \end{DoxyCompactList}\item 
\#define \hyperlink{orte__wait_8h_a4435868bc0689e7948304d30bab275f7}{O\+R\+T\+E\+\_\+\+T\+I\+M\+E\+R\+\_\+\+E\+V\+E\+N\+T}(sec, usec, cbfunc)
\begin{DoxyCompactList}\small\item\em There are places in the code where we just want to periodically wakeup to do something, and then go back to sleep again. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Typedefs}
\begin{DoxyCompactItemize}
\item 
\hypertarget{orte__wait_8h_aa4818b9f56917fe772837cf5e4fb8b80}{typedef void($\ast$ \hyperlink{orte__wait_8h_aa4818b9f56917fe772837cf5e4fb8b80}{orte\+\_\+wait\+\_\+fn\+\_\+t} )(pid\+\_\+t wpid, int status, void $\ast$data)}\label{orte__wait_8h_aa4818b9f56917fe772837cf5e4fb8b80}

\begin{DoxyCompactList}\small\item\em typedef for callback function used in {\ttfamily ompi\+\_\+rte\+\_\+wait\+\_\+cb} \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
\hypertarget{orte__wait_8h_a28d10d876981177729b5a7e007dc1ea2}{O\+R\+T\+E\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C {\bfseries O\+B\+J\+\_\+\+C\+L\+A\+S\+S\+\_\+\+D\+E\+C\+L\+A\+R\+A\+T\+I\+O\+N} (\hyperlink{structorte__trigger__event__t}{orte\+\_\+trigger\+\_\+event\+\_\+t})}\label{orte__wait_8h_a28d10d876981177729b5a7e007dc1ea2}

\item 
O\+R\+T\+E\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C void \hyperlink{orte__wait_8h_ad353c90d78ddce0e64c0ff934282c520}{orte\+\_\+wait\+\_\+enable} (void)
\begin{DoxyCompactList}\small\item\em Disable / re-\/\+Enable S\+I\+G\+C\+H\+L\+D handler. \end{DoxyCompactList}\item 
\hypertarget{orte__wait_8h_a79cd0090f8bd373866baf0959f829df3}{O\+R\+T\+E\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C void {\bfseries orte\+\_\+wait\+\_\+disable} (void)}\label{orte__wait_8h_a79cd0090f8bd373866baf0959f829df3}

\item 
O\+R\+T\+E\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C pid\+\_\+t \hyperlink{orte__wait_8h_ab1dda30b538b9d9ccfbcbd50159b14a0}{orte\+\_\+waitpid} (pid\+\_\+t wpid, int $\ast$status, int options)
\begin{DoxyCompactList}\small\item\em Wait for process terminiation. \end{DoxyCompactList}\item 
O\+R\+T\+E\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C int \hyperlink{orte__wait_8h_af98c6f684bc407c88ccbb7b2b5085a69}{orte\+\_\+wait\+\_\+cb} (pid\+\_\+t wpid, \hyperlink{orte__wait_8h_aa4818b9f56917fe772837cf5e4fb8b80}{orte\+\_\+wait\+\_\+fn\+\_\+t} callback, void $\ast$data)
\begin{DoxyCompactList}\small\item\em Register a callback for process termination. \end{DoxyCompactList}\item 
\hypertarget{orte__wait_8h_ab39691c840067c5ef5257106cce8ee23}{O\+R\+T\+E\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C int {\bfseries orte\+\_\+wait\+\_\+cb\+\_\+cancel} (pid\+\_\+t wpid)}\label{orte__wait_8h_ab39691c840067c5ef5257106cce8ee23}

\item 
\hypertarget{orte__wait_8h_a9a83484ef4d95b686edbda62fd8819b3}{O\+R\+T\+E\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C int {\bfseries orte\+\_\+wait\+\_\+cb\+\_\+disable} (void)}\label{orte__wait_8h_a9a83484ef4d95b686edbda62fd8819b3}

\item 
\hypertarget{orte__wait_8h_a66a7d29c27c8ed907dd640609aa0ccdd}{O\+R\+T\+E\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C int {\bfseries orte\+\_\+wait\+\_\+cb\+\_\+enable} (void)}\label{orte__wait_8h_a66a7d29c27c8ed907dd640609aa0ccdd}

\item 
O\+R\+T\+E\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C int \hyperlink{orte__wait_8h_afb5bcd1844c18a067a27d6d896e88c70}{orte\+\_\+wait\+\_\+event} (\hyperlink{structevent}{opal\+\_\+event\+\_\+t} $\ast$$\ast$\hyperlink{structevent}{event}, \hyperlink{structorte__trigger__event__t}{orte\+\_\+trigger\+\_\+event\+\_\+t} $\ast$trig, char $\ast$trigger\+\_\+name, void($\ast$cbfunc)(int, short, void $\ast$))
\begin{DoxyCompactList}\small\item\em Setup to wait for an event. \end{DoxyCompactList}\item 
O\+R\+T\+E\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C void \hyperlink{orte__wait_8h_aabe6c644f8ee738d474a3d3b6683d4fc}{orte\+\_\+trigger\+\_\+event} (\hyperlink{structorte__trigger__event__t}{orte\+\_\+trigger\+\_\+event\+\_\+t} $\ast$trig)
\begin{DoxyCompactList}\small\item\em Trigger a defined event. \end{DoxyCompactList}\item 
\hypertarget{orte__wait_8h_a1b40b899f6a45f0161e57671a7834b65}{O\+R\+T\+E\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C {\bfseries O\+B\+J\+\_\+\+C\+L\+A\+S\+S\+\_\+\+D\+E\+C\+L\+A\+R\+A\+T\+I\+O\+N} (\hyperlink{structorte__message__event__t}{orte\+\_\+message\+\_\+event\+\_\+t})}\label{orte__wait_8h_a1b40b899f6a45f0161e57671a7834b65}

\item 
\hypertarget{orte__wait_8h_ab9126e228dec3cd0c1328c4cc79af857}{O\+R\+T\+E\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C {\bfseries O\+B\+J\+\_\+\+C\+L\+A\+S\+S\+\_\+\+D\+E\+C\+L\+A\+R\+A\+T\+I\+O\+N} (\hyperlink{structorte__notify__event__t}{orte\+\_\+notify\+\_\+event\+\_\+t})}\label{orte__wait_8h_ab9126e228dec3cd0c1328c4cc79af857}

\item 
\hypertarget{orte__wait_8h_a8c24a8cb2f9959cc4401c053f5f9ae2a}{O\+R\+T\+E\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C int {\bfseries orte\+\_\+wait\+\_\+init} (void)}\label{orte__wait_8h_a8c24a8cb2f9959cc4401c053f5f9ae2a}

\item 
\hypertarget{orte__wait_8h_ac1854497a60c01541b1321d3456d4fcb}{O\+R\+T\+E\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C int \hyperlink{orte__wait_8h_ac1854497a60c01541b1321d3456d4fcb}{orte\+\_\+wait\+\_\+kill} (int sig)}\label{orte__wait_8h_ac1854497a60c01541b1321d3456d4fcb}

\begin{DoxyCompactList}\small\item\em Kill all processes we are waiting on. \end{DoxyCompactList}\item 
\hypertarget{orte__wait_8h_a0e08fb9df6d9d9ceec0d0d584a5d007e}{O\+R\+T\+E\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C int {\bfseries orte\+\_\+wait\+\_\+finalize} (void)}\label{orte__wait_8h_a0e08fb9df6d9d9ceec0d0d584a5d007e}

\end{DoxyCompactItemize}


\subsection{Detailed Description}
Interface for waitpid / async notification of child death with the libevent runtime system. 



\subsection{Macro Definition Documentation}
\hypertarget{orte__wait_8h_a56bd663963b0bdb8a2843f25dd98a279}{\index{orte\+\_\+wait.\+h@{orte\+\_\+wait.\+h}!O\+R\+T\+E\+\_\+\+D\+E\+T\+E\+C\+T\+\_\+\+T\+I\+M\+E\+O\+U\+T@{O\+R\+T\+E\+\_\+\+D\+E\+T\+E\+C\+T\+\_\+\+T\+I\+M\+E\+O\+U\+T}}
\index{O\+R\+T\+E\+\_\+\+D\+E\+T\+E\+C\+T\+\_\+\+T\+I\+M\+E\+O\+U\+T@{O\+R\+T\+E\+\_\+\+D\+E\+T\+E\+C\+T\+\_\+\+T\+I\+M\+E\+O\+U\+T}!orte\+\_\+wait.\+h@{orte\+\_\+wait.\+h}}
\subsubsection[{O\+R\+T\+E\+\_\+\+D\+E\+T\+E\+C\+T\+\_\+\+T\+I\+M\+E\+O\+U\+T}]{\setlength{\rightskip}{0pt plus 5cm}\#define O\+R\+T\+E\+\_\+\+D\+E\+T\+E\+C\+T\+\_\+\+T\+I\+M\+E\+O\+U\+T(
\begin{DoxyParamCaption}
\item[{}]{{\bf event}, }
\item[{}]{n, }
\item[{}]{deltat, }
\item[{}]{maxwait, }
\item[{}]{cbfunc}
\end{DoxyParamCaption}
)}}\label{orte__wait_8h_a56bd663963b0bdb8a2843f25dd98a279}
{\bfseries Value\+:}
\begin{DoxyCode}
\textcolor{keywordflow}{do} \{                                                                    \(\backslash\)
        struct timeval now;                                                 \(\backslash\)
        opal\_event\_t *tmp;                                                  \(\backslash\)
        int timeout;                                                        \(\backslash\)
        tmp =  (\hyperlink{structevent}{opal\_event\_t} *) malloc(\textcolor{keyword}{sizeof}(\hyperlink{structevent}{opal\_event\_t}));               \(\backslash\)
        opal\_event\_evtimer\_set(opal\_event\_base,                             \(\backslash\)
                               tmp, (cbfunc), tmp);                         \(\backslash\)
        timeout = (deltat) * (n);                                           \(\backslash\)
        if ((maxwait) > 0 && timeout > (maxwait)) \{                         \(\backslash\)
            timeout = (maxwait);                                            \(\backslash\)
        \}                                                                   \(\backslash\)
        now.tv\_sec = timeout/1000000;                                       \(\backslash\)
        now.tv\_usec = timeout%1000000;                                      \hyperlink{output_8h_ac1802ce1863ea1add58d6b8d248f0597}{\(\backslash\)}
\hyperlink{output_8h_ac1802ce1863ea1add58d6b8d248f0597}{        OPAL\_OUTPUT\_VERBOSE}((1, orte\_debug\_output,                          \(\backslash\)
                             \textcolor{stringliteral}{"defining timeout: %ld sec %ld usec at %s:%d"}, \(\backslash\)
                            (\textcolor{keywordtype}{long})now.tv\_sec, (\textcolor{keywordtype}{long})now.tv\_usec,            \(\backslash\)
                            \_\_FILE\_\_, \_\_LINE\_\_));                           \(\backslash\)
        opal\_event\_evtimer\_add(tmp, &now);                                  \(\backslash\)
        *(\hyperlink{structevent}{event}) = tmp;                                                     \(\backslash\)
    \}\textcolor{keywordflow}{while}(0);                                                              \(\backslash\)
\end{DoxyCode}


In a number of places within the code, we want to setup a timer to detect when some procedure failed to complete. 

For example, when we launch the daemons, we frequently have no way to directly detect that a daemon failed to launch. Setting a timer allows us to automatically fail out of the launch if we don't hear from a daemon in some specified time window.

Computing the amount of time to wait takes a few lines of code, but this macro encapsulates those lines along with the timer event definition just as a convenience. It also centralizes the necessary checks to ensure that the microsecond field is always less than 1\+M since some systems care about that, and to ensure that the computed wait time doesn't exceed the desired max wait 

Referenced by orte\+\_\+plm\+\_\+base\+\_\+orted\+\_\+exit().

\hypertarget{orte__wait_8h_a12b27af6372f050a0f21a20aff8637b6}{\index{orte\+\_\+wait.\+h@{orte\+\_\+wait.\+h}!O\+R\+T\+E\+\_\+\+M\+E\+S\+S\+A\+G\+E\+\_\+\+E\+V\+E\+N\+T@{O\+R\+T\+E\+\_\+\+M\+E\+S\+S\+A\+G\+E\+\_\+\+E\+V\+E\+N\+T}}
\index{O\+R\+T\+E\+\_\+\+M\+E\+S\+S\+A\+G\+E\+\_\+\+E\+V\+E\+N\+T@{O\+R\+T\+E\+\_\+\+M\+E\+S\+S\+A\+G\+E\+\_\+\+E\+V\+E\+N\+T}!orte\+\_\+wait.\+h@{orte\+\_\+wait.\+h}}
\subsubsection[{O\+R\+T\+E\+\_\+\+M\+E\+S\+S\+A\+G\+E\+\_\+\+E\+V\+E\+N\+T}]{\setlength{\rightskip}{0pt plus 5cm}\#define O\+R\+T\+E\+\_\+\+M\+E\+S\+S\+A\+G\+E\+\_\+\+E\+V\+E\+N\+T(
\begin{DoxyParamCaption}
\item[{}]{sndr, }
\item[{}]{buf, }
\item[{}]{tg, }
\item[{}]{cbfunc}
\end{DoxyParamCaption}
)}}\label{orte__wait_8h_a12b27af6372f050a0f21a20aff8637b6}
{\bfseries Value\+:}
\begin{DoxyCode}
\textcolor{keywordflow}{do} \{                                                        \(\backslash\)
        orte\_message\_event\_t *mev;                              \(\backslash\)
        struct timeval now;                                     \hyperlink{output_8h_ac1802ce1863ea1add58d6b8d248f0597}{\(\backslash\)}
\hyperlink{output_8h_ac1802ce1863ea1add58d6b8d248f0597}{        OPAL\_OUTPUT\_VERBOSE}((1, orte\_debug\_output,              \(\backslash\)
                            \textcolor{stringliteral}{"defining message event: %s %d"},    \(\backslash\)
                            \_\_FILE\_\_, \_\_LINE\_\_));               \(\backslash\)
        mev = OBJ\_NEW(\hyperlink{structorte__message__event__t}{orte\_message\_event\_t});                    \(\backslash\)
        mev->sender.jobid = (sndr)->jobid;                      \(\backslash\)
        mev->sender.vpid = (sndr)->vpid;                        \(\backslash\)
        ORTE\_EPOCH\_SET(mev->sender.epoch,(sndr)->epoch);        \(\backslash\)
        opal\_dss.copy\_payload(mev->buffer, (buf));              \(\backslash\)
        mev->tag = (tg);                                        \(\backslash\)
        opal\_event\_evtimer\_set(opal\_event\_base,                 \(\backslash\)
                               mev->ev, (cbfunc), mev);         \(\backslash\)
        now.tv\_sec = 0;                                         \(\backslash\)
        now.tv\_usec = 0;                                        \(\backslash\)
        opal\_event\_evtimer\_add(mev->ev, &now);                  \(\backslash\)
    \} \textcolor{keywordflow}{while}(0);
\end{DoxyCode}
\hypertarget{orte__wait_8h_a03c25c79e96aaff8cfe2ebe6f39af29f}{\index{orte\+\_\+wait.\+h@{orte\+\_\+wait.\+h}!O\+R\+T\+E\+\_\+\+M\+E\+S\+S\+A\+G\+E\+\_\+\+E\+V\+E\+N\+T\+\_\+\+D\+E\+L\+A\+Y@{O\+R\+T\+E\+\_\+\+M\+E\+S\+S\+A\+G\+E\+\_\+\+E\+V\+E\+N\+T\+\_\+\+D\+E\+L\+A\+Y}}
\index{O\+R\+T\+E\+\_\+\+M\+E\+S\+S\+A\+G\+E\+\_\+\+E\+V\+E\+N\+T\+\_\+\+D\+E\+L\+A\+Y@{O\+R\+T\+E\+\_\+\+M\+E\+S\+S\+A\+G\+E\+\_\+\+E\+V\+E\+N\+T\+\_\+\+D\+E\+L\+A\+Y}!orte\+\_\+wait.\+h@{orte\+\_\+wait.\+h}}
\subsubsection[{O\+R\+T\+E\+\_\+\+M\+E\+S\+S\+A\+G\+E\+\_\+\+E\+V\+E\+N\+T\+\_\+\+D\+E\+L\+A\+Y}]{\setlength{\rightskip}{0pt plus 5cm}\#define O\+R\+T\+E\+\_\+\+M\+E\+S\+S\+A\+G\+E\+\_\+\+E\+V\+E\+N\+T\+\_\+\+D\+E\+L\+A\+Y(
\begin{DoxyParamCaption}
\item[{}]{delay, }
\item[{}]{mev}
\end{DoxyParamCaption}
)}}\label{orte__wait_8h_a03c25c79e96aaff8cfe2ebe6f39af29f}
{\bfseries Value\+:}
\begin{DoxyCode}
\textcolor{keywordflow}{do} \{                                                            \(\backslash\)
        struct timeval now;                                         \hyperlink{output_8h_ac1802ce1863ea1add58d6b8d248f0597}{\(\backslash\)}
\hyperlink{output_8h_ac1802ce1863ea1add58d6b8d248f0597}{        OPAL\_OUTPUT\_VERBOSE}((1, orte\_debug\_output,                  \(\backslash\)
                            \textcolor{stringliteral}{"defining message event delay: %s %d"},  \(\backslash\)
                            \_\_FILE\_\_, \_\_LINE\_\_));                   \(\backslash\)
        now.tv\_sec = delay/1000000;                                 \(\backslash\)
        now.tv\_usec = delay%1000000;                                \(\backslash\)
        opal\_event\_evtimer\_add(mev->ev, &now);                      \(\backslash\)
    \} \textcolor{keywordflow}{while}(0);
\end{DoxyCode}
\hypertarget{orte__wait_8h_a31963f2a190461b96de91bb859668c63}{\index{orte\+\_\+wait.\+h@{orte\+\_\+wait.\+h}!O\+R\+T\+E\+\_\+\+N\+O\+T\+I\+F\+Y\+\_\+\+E\+V\+E\+N\+T@{O\+R\+T\+E\+\_\+\+N\+O\+T\+I\+F\+Y\+\_\+\+E\+V\+E\+N\+T}}
\index{O\+R\+T\+E\+\_\+\+N\+O\+T\+I\+F\+Y\+\_\+\+E\+V\+E\+N\+T@{O\+R\+T\+E\+\_\+\+N\+O\+T\+I\+F\+Y\+\_\+\+E\+V\+E\+N\+T}!orte\+\_\+wait.\+h@{orte\+\_\+wait.\+h}}
\subsubsection[{O\+R\+T\+E\+\_\+\+N\+O\+T\+I\+F\+Y\+\_\+\+E\+V\+E\+N\+T}]{\setlength{\rightskip}{0pt plus 5cm}\#define O\+R\+T\+E\+\_\+\+N\+O\+T\+I\+F\+Y\+\_\+\+E\+V\+E\+N\+T(
\begin{DoxyParamCaption}
\item[{}]{cbfunc, }
\item[{}]{data}
\end{DoxyParamCaption}
)}}\label{orte__wait_8h_a31963f2a190461b96de91bb859668c63}
{\bfseries Value\+:}
\begin{DoxyCode}
\textcolor{keywordflow}{do} \{                                                        \(\backslash\)
        struct timeval now;                                     \(\backslash\)
        orte\_notify\_event\_t *tmp;                               \(\backslash\)
        tmp = OBJ\_NEW(\hyperlink{structorte__notify__event__t}{orte\_notify\_event\_t});                     \(\backslash\)
        tmp->proc.jobid = (data)->jobid;                        \(\backslash\)
        tmp->proc.vpid = (data)->vpid;                          \(\backslash\)
        ORTE\_EPOCH\_SET(tmp->proc.epoch,(data)->epoch);          \(\backslash\)
        opal\_event.evtimer\_set(opal\_event\_base,                 \(\backslash\)
                               tmp->ev, (cbfunc), tmp);         \(\backslash\)
        now.tv\_sec = 0;                                         \(\backslash\)
        now.tv\_usec = 0;                                        \hyperlink{output_8h_ac1802ce1863ea1add58d6b8d248f0597}{\(\backslash\)}
\hyperlink{output_8h_ac1802ce1863ea1add58d6b8d248f0597}{        OPAL\_OUTPUT\_VERBOSE}((1, orte\_debug\_output,              \(\backslash\)
                            \textcolor{stringliteral}{"defining notify event at %s:%d"},   \(\backslash\)
                            \_\_FILE\_\_, \_\_LINE\_\_));               \(\backslash\)
        opal\_event\_evtimer\_add(tmp->ev, &now);                  \(\backslash\)
    \} \textcolor{keywordflow}{while}(0);                                                 \(\backslash\)
\end{DoxyCode}
\hypertarget{orte__wait_8h_a1f38f222c63cfac9974311f0d6a6befa}{\index{orte\+\_\+wait.\+h@{orte\+\_\+wait.\+h}!O\+R\+T\+E\+\_\+\+P\+R\+O\+G\+R\+E\+S\+S\+E\+D\+\_\+\+W\+A\+I\+T@{O\+R\+T\+E\+\_\+\+P\+R\+O\+G\+R\+E\+S\+S\+E\+D\+\_\+\+W\+A\+I\+T}}
\index{O\+R\+T\+E\+\_\+\+P\+R\+O\+G\+R\+E\+S\+S\+E\+D\+\_\+\+W\+A\+I\+T@{O\+R\+T\+E\+\_\+\+P\+R\+O\+G\+R\+E\+S\+S\+E\+D\+\_\+\+W\+A\+I\+T}!orte\+\_\+wait.\+h@{orte\+\_\+wait.\+h}}
\subsubsection[{O\+R\+T\+E\+\_\+\+P\+R\+O\+G\+R\+E\+S\+S\+E\+D\+\_\+\+W\+A\+I\+T}]{\setlength{\rightskip}{0pt plus 5cm}\#define O\+R\+T\+E\+\_\+\+P\+R\+O\+G\+R\+E\+S\+S\+E\+D\+\_\+\+W\+A\+I\+T(
\begin{DoxyParamCaption}
\item[{}]{failed, }
\item[{}]{counter, }
\item[{}]{limit}
\end{DoxyParamCaption}
)}}\label{orte__wait_8h_a1f38f222c63cfac9974311f0d6a6befa}
{\bfseries Value\+:}
\begin{DoxyCode}
\textcolor{keywordflow}{do} \{                                                  \hyperlink{output_8h_ac1802ce1863ea1add58d6b8d248f0597}{\(\backslash\)}
\hyperlink{output_8h_ac1802ce1863ea1add58d6b8d248f0597}{        OPAL\_OUTPUT\_VERBOSE}((1, orte\_debug\_output,        \(\backslash\)
                            \textcolor{stringliteral}{"progressed\_wait: %s %d"},     \(\backslash\)
                             \_\_FILE\_\_, \_\_LINE\_\_));        \(\backslash\)
        while (!(failed) && (counter) < (limit)) \{        \hyperlink{opal__progress_8h_a89fcac5ab9895b0823687d1f56d883a4}{\(\backslash\)}
\hyperlink{opal__progress_8h_a89fcac5ab9895b0823687d1f56d883a4}{            opal\_progress}();                              \(\backslash\)
        \}                                                 \(\backslash\)
    \} \textcolor{keywordflow}{while}(0);                                           \(\backslash\)
\end{DoxyCode}


In a number of places in the code, we need to wait for something to complete -\/ for example, waiting for all launched procs to report into the H\+N\+P. 

In such cases, we want to just call progress so that any messages get processed, but otherwise \char`\"{}hold\char`\"{} the program at this spot until the counter achieves the specified value. We also want to provide a boolean flag, though, so that we break out of the loop should something go wrong. 

Referenced by orte\+\_\+plm\+\_\+base\+\_\+orted\+\_\+exit().

\hypertarget{orte__wait_8h_a4435868bc0689e7948304d30bab275f7}{\index{orte\+\_\+wait.\+h@{orte\+\_\+wait.\+h}!O\+R\+T\+E\+\_\+\+T\+I\+M\+E\+R\+\_\+\+E\+V\+E\+N\+T@{O\+R\+T\+E\+\_\+\+T\+I\+M\+E\+R\+\_\+\+E\+V\+E\+N\+T}}
\index{O\+R\+T\+E\+\_\+\+T\+I\+M\+E\+R\+\_\+\+E\+V\+E\+N\+T@{O\+R\+T\+E\+\_\+\+T\+I\+M\+E\+R\+\_\+\+E\+V\+E\+N\+T}!orte\+\_\+wait.\+h@{orte\+\_\+wait.\+h}}
\subsubsection[{O\+R\+T\+E\+\_\+\+T\+I\+M\+E\+R\+\_\+\+E\+V\+E\+N\+T}]{\setlength{\rightskip}{0pt plus 5cm}\#define O\+R\+T\+E\+\_\+\+T\+I\+M\+E\+R\+\_\+\+E\+V\+E\+N\+T(
\begin{DoxyParamCaption}
\item[{}]{sec, }
\item[{}]{usec, }
\item[{}]{cbfunc}
\end{DoxyParamCaption}
)}}\label{orte__wait_8h_a4435868bc0689e7948304d30bab275f7}
{\bfseries Value\+:}
\begin{DoxyCode}
\textcolor{keywordflow}{do} \{                                                                        \(\backslash\)
        struct timeval now;                                                     \(\backslash\)
        opal\_event\_t *tmp;                                                      \(\backslash\)
        tmp =  (\hyperlink{structevent}{opal\_event\_t} *) malloc(\textcolor{keyword}{sizeof}(\hyperlink{structevent}{opal\_event\_t}));                   \(\backslash\)
        opal\_event\_evtimer\_set(opal\_event\_base,                                 \(\backslash\)
                               tmp, (cbfunc), tmp);                             \(\backslash\)
        now.tv\_sec = (sec);                                                     \(\backslash\)
        now.tv\_usec = (usec);                                                   
      \hyperlink{output_8h_ac1802ce1863ea1add58d6b8d248f0597}{\(\backslash\)}
\hyperlink{output_8h_ac1802ce1863ea1add58d6b8d248f0597}{        OPAL\_OUTPUT\_VERBOSE}((1, orte\_debug\_output,                              
      \(\backslash\)
                            \textcolor{stringliteral}{"defining timer event: %ld sec %ld usec at %s:%d"},  \(\backslash\)
                            (\textcolor{keywordtype}{long})now.tv\_sec, (\textcolor{keywordtype}{long})now.tv\_usec,                \(\backslash\)
                            \_\_FILE\_\_, \_\_LINE\_\_));                               \(\backslash\)
        opal\_event\_evtimer\_add(tmp, &now);                                      \(\backslash\)
    \}\textcolor{keywordflow}{while}(0);                                                                  \(\backslash\)
\end{DoxyCode}


There are places in the code where we just want to periodically wakeup to do something, and then go back to sleep again. 

Setting a timer allows us to do this 

\subsection{Function Documentation}
\hypertarget{orte__wait_8h_aabe6c644f8ee738d474a3d3b6683d4fc}{\index{orte\+\_\+wait.\+h@{orte\+\_\+wait.\+h}!orte\+\_\+trigger\+\_\+event@{orte\+\_\+trigger\+\_\+event}}
\index{orte\+\_\+trigger\+\_\+event@{orte\+\_\+trigger\+\_\+event}!orte\+\_\+wait.\+h@{orte\+\_\+wait.\+h}}
\subsubsection[{orte\+\_\+trigger\+\_\+event}]{\setlength{\rightskip}{0pt plus 5cm}O\+R\+T\+E\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C void orte\+\_\+trigger\+\_\+event (
\begin{DoxyParamCaption}
\item[{{\bf orte\+\_\+trigger\+\_\+event\+\_\+t} $\ast$}]{trig}
\end{DoxyParamCaption}
)}}\label{orte__wait_8h_aabe6c644f8ee738d474a3d3b6683d4fc}


Trigger a defined event. 

This function will trigger a previously-\/defined event -\/ as setup by orte\+\_\+wait\+\_\+event -\/ by firing the provided trigger \hypertarget{orte__wait_8h_af98c6f684bc407c88ccbb7b2b5085a69}{\index{orte\+\_\+wait.\+h@{orte\+\_\+wait.\+h}!orte\+\_\+wait\+\_\+cb@{orte\+\_\+wait\+\_\+cb}}
\index{orte\+\_\+wait\+\_\+cb@{orte\+\_\+wait\+\_\+cb}!orte\+\_\+wait.\+h@{orte\+\_\+wait.\+h}}
\subsubsection[{orte\+\_\+wait\+\_\+cb}]{\setlength{\rightskip}{0pt plus 5cm}O\+R\+T\+E\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C int orte\+\_\+wait\+\_\+cb (
\begin{DoxyParamCaption}
\item[{pid\+\_\+t}]{wpid, }
\item[{{\bf orte\+\_\+wait\+\_\+fn\+\_\+t}}]{callback, }
\item[{void $\ast$}]{data}
\end{DoxyParamCaption}
)}}\label{orte__wait_8h_af98c6f684bc407c88ccbb7b2b5085a69}


Register a callback for process termination. 

Register a callback for notification when {\ttfamily wpid} causes a S\+I\+G\+C\+H\+L\+D. {\ttfamily waitpid()} will have already been called on the process at this time.

If a thread is already blocked in {\ttfamily ompi\+\_\+rte\+\_\+waitpid} for {\ttfamily wpid}, this function will return {\ttfamily O\+R\+T\+E\+\_\+\+E\+R\+R\+\_\+\+E\+X\+I\+S\+T\+S}. It is illegal for multiple callbacks to be registered for a single {\ttfamily wpid} (O\+M\+P\+I\+\_\+\+E\+X\+I\+S\+T\+S will be returned in this case).

\begin{DoxyWarning}{Warning}
It is not legal for {\ttfamily wpid} to be -\/1 when registering a callback. 
\end{DoxyWarning}


Referenced by orte\+\_\+plm\+\_\+submit\+\_\+launch().

\hypertarget{orte__wait_8h_ad353c90d78ddce0e64c0ff934282c520}{\index{orte\+\_\+wait.\+h@{orte\+\_\+wait.\+h}!orte\+\_\+wait\+\_\+enable@{orte\+\_\+wait\+\_\+enable}}
\index{orte\+\_\+wait\+\_\+enable@{orte\+\_\+wait\+\_\+enable}!orte\+\_\+wait.\+h@{orte\+\_\+wait.\+h}}
\subsubsection[{orte\+\_\+wait\+\_\+enable}]{\setlength{\rightskip}{0pt plus 5cm}O\+R\+T\+E\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C void orte\+\_\+wait\+\_\+enable (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)}}\label{orte__wait_8h_ad353c90d78ddce0e64c0ff934282c520}


Disable / re-\/\+Enable S\+I\+G\+C\+H\+L\+D handler. 

These functions have to be used after orte\+\_\+wait\+\_\+init was called. \hypertarget{orte__wait_8h_afb5bcd1844c18a067a27d6d896e88c70}{\index{orte\+\_\+wait.\+h@{orte\+\_\+wait.\+h}!orte\+\_\+wait\+\_\+event@{orte\+\_\+wait\+\_\+event}}
\index{orte\+\_\+wait\+\_\+event@{orte\+\_\+wait\+\_\+event}!orte\+\_\+wait.\+h@{orte\+\_\+wait.\+h}}
\subsubsection[{orte\+\_\+wait\+\_\+event}]{\setlength{\rightskip}{0pt plus 5cm}O\+R\+T\+E\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C int orte\+\_\+wait\+\_\+event (
\begin{DoxyParamCaption}
\item[{{\bf opal\+\_\+event\+\_\+t} $\ast$$\ast$}]{event, }
\item[{{\bf orte\+\_\+trigger\+\_\+event\+\_\+t} $\ast$}]{trig, }
\item[{char $\ast$}]{trigger\+\_\+name, }
\item[{void($\ast$)(int, short, void $\ast$)}]{cbfunc}
\end{DoxyParamCaption}
)}}\label{orte__wait_8h_afb5bcd1844c18a067a27d6d896e88c70}


Setup to wait for an event. 

This function is used to setup a trigger event that can be used elsewhere in the code base where we want to wait for some event to happen. For example, orterun uses this function to setup an event that is used to notify orterun of abnormal and normal termination so it can wakeup and exit cleanly.

The event will be defined so that firing the provided trigger will cause the event to trigger and callback to the provided function \hypertarget{orte__wait_8h_ab1dda30b538b9d9ccfbcbd50159b14a0}{\index{orte\+\_\+wait.\+h@{orte\+\_\+wait.\+h}!orte\+\_\+waitpid@{orte\+\_\+waitpid}}
\index{orte\+\_\+waitpid@{orte\+\_\+waitpid}!orte\+\_\+wait.\+h@{orte\+\_\+wait.\+h}}
\subsubsection[{orte\+\_\+waitpid}]{\setlength{\rightskip}{0pt plus 5cm}O\+R\+T\+E\+\_\+\+D\+E\+C\+L\+S\+P\+E\+C pid\+\_\+t orte\+\_\+waitpid (
\begin{DoxyParamCaption}
\item[{pid\+\_\+t}]{wpid, }
\item[{int $\ast$}]{status, }
\item[{int}]{options}
\end{DoxyParamCaption}
)}}\label{orte__wait_8h_ab1dda30b538b9d9ccfbcbd50159b14a0}


Wait for process terminiation. 

Similar to {\ttfamily waitpid}, {\ttfamily orte\+\_\+waitpid} utilizes the run-\/time event library for process terminiation notification. The {\ttfamily W\+U\+N\+T\+R\+A\+C\+E\+D} option is not supported, but the {\ttfamily W\+N\+O\+H\+A\+N\+G} option is supported.

\begin{DoxyNote}{Note}
A {\ttfamily wpid} value of {\ttfamily -\/1} is not currently supported and will return an error. 
\end{DoxyNote}
