1999-01-02 18:02:30 -05: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 08:34:57 -05:00
|
|
|
Example of using it:
|
|
|
|
|
|
|
|
\begin{verbatim}
|
2002-06-07 16:15:28 -04:00
|
|
|
void Set Foo()
|
1999-11-15 08:34:57 -05:00
|
|
|
{
|
|
|
|
// 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 18:02:30 -05:00
|
|
|
\wxheading{Derived from}
|
|
|
|
|
|
|
|
None.
|
|
|
|
|
1999-02-15 15:41:29 -05:00
|
|
|
\wxheading{Include files}
|
|
|
|
|
|
|
|
<wx/thread.h>
|
|
|
|
|
2007-07-28 08:21:03 -04:00
|
|
|
\wxheading{Library}
|
|
|
|
|
|
|
|
\helpref{wxBase}{librarieslist}
|
|
|
|
|
1999-01-02 18:02:30 -05:00
|
|
|
\wxheading{See also}
|
|
|
|
|
1999-01-17 14:25:06 -05:00
|
|
|
\helpref{wxCriticalSection}{wxcriticalsection},
|
1999-01-02 18:02:30 -05:00
|
|
|
\helpref{wxMutexLocker}{wxmutexlocker}
|
|
|
|
|
|
|
|
\latexignore{\rtfignore{\wxheading{Members}}}
|
|
|
|
|
|
|
|
\membersection{wxCriticalSectionLocker::wxCriticalSectionLocker}\label{wxcriticalsectionlockerctor}
|
1999-01-17 14:25:06 -05:00
|
|
|
|
1999-11-15 08:34:57 -05:00
|
|
|
\func{}{wxCriticalSectionLocker}{\param{wxCriticalSection\& }{criticalsection}}
|
1999-01-02 18:02:30 -05:00
|
|
|
|
|
|
|
Constructs a wxCriticalSectionLocker object associated with given
|
1999-11-15 08:34:57 -05:00
|
|
|
{\it criticalsection} and enters it.
|
1999-01-02 18:02:30 -05:00
|
|
|
|
|
|
|
\membersection{wxCriticalSectionLocker::\destruct{wxCriticalSectionLocker}}\label{wxcriticalsectionlockerdtor}
|
1999-01-17 14:25:06 -05:00
|
|
|
|
1999-01-02 18:02:30 -05:00
|
|
|
\func{}{\destruct{wxCriticalSectionLocker}}{\void}
|
|
|
|
|
2002-06-07 16:15:28 -04:00
|
|
|
Destructor leaves the critical section.
|
1999-01-17 14:25:06 -05:00
|
|
|
|