1999-01-02 23:02:30 +00:00
|
|
|
\section{\class{wxCriticalSectionLocker}}\label{wxcriticalsectionlocker}
|
|
|
|
|
|
|
|
This is a small helper class to be used with \helpref{wxCriticalSection}{wxcriticalsection}
|
|
|
|
objects. A wxCriticalSectionLocker enters the critical section in the
|
|
|
|
constructor and leaves it in the destructor making it much more difficult to
|
|
|
|
forget to leave a critical section (which, in general, will lead to serious
|
|
|
|
and difficult to debug problems).
|
|
|
|
|
1999-11-15 13:34:57 +00:00
|
|
|
Example of using it:
|
|
|
|
|
|
|
|
\begin{verbatim}
|
|
|
|
void SetFoo()
|
|
|
|
{
|
|
|
|
// gs_critSect is some (global) critical section guarding access to the
|
|
|
|
// object "foo"
|
|
|
|
wxCriticalSectionLocker locker(gs_critSect);
|
|
|
|
|
|
|
|
if ( ... )
|
|
|
|
{
|
|
|
|
// do something
|
|
|
|
...
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// do something else
|
|
|
|
...
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
\end{verbatim}
|
|
|
|
|
|
|
|
Without wxCriticalSectionLocker, you would need to remember to manually leave
|
|
|
|
the critical section before each {\tt return}.
|
|
|
|
|
1999-01-02 23:02:30 +00:00
|
|
|
\wxheading{Derived from}
|
|
|
|
|
|
|
|
None.
|
|
|
|
|
1999-02-15 20:41:29 +00:00
|
|
|
\wxheading{Include files}
|
|
|
|
|
|
|
|
<wx/thread.h>
|
|
|
|
|
1999-01-02 23:02:30 +00:00
|
|
|
\wxheading{See also}
|
|
|
|
|
1999-01-17 19:25:06 +00:00
|
|
|
\helpref{wxCriticalSection}{wxcriticalsection},
|
1999-01-02 23:02:30 +00:00
|
|
|
\helpref{wxMutexLocker}{wxmutexlocker}
|
|
|
|
|
|
|
|
\latexignore{\rtfignore{\wxheading{Members}}}
|
|
|
|
|
|
|
|
\membersection{wxCriticalSectionLocker::wxCriticalSectionLocker}\label{wxcriticalsectionlockerctor}
|
1999-01-17 19:25:06 +00:00
|
|
|
|
1999-11-15 13:34:57 +00:00
|
|
|
\func{}{wxCriticalSectionLocker}{\param{wxCriticalSection\& }{criticalsection}}
|
1999-01-02 23:02:30 +00:00
|
|
|
|
|
|
|
Constructs a wxCriticalSectionLocker object associated with given
|
1999-11-15 13:34:57 +00:00
|
|
|
{\it criticalsection} and enters it.
|
1999-01-02 23:02:30 +00:00
|
|
|
|
|
|
|
\membersection{wxCriticalSectionLocker::\destruct{wxCriticalSectionLocker}}\label{wxcriticalsectionlockerdtor}
|
1999-01-17 19:25:06 +00:00
|
|
|
|
1999-01-02 23:02:30 +00:00
|
|
|
\func{}{\destruct{wxCriticalSectionLocker}}{\void}
|
|
|
|
|
1999-11-15 13:34:57 +00:00
|
|
|
Destuctor leaves the critical section.
|
1999-01-17 19:25:06 +00:00
|
|
|
|