git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15779 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
		
			
				
	
	
		
			64 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			TeX
		
	
	
	
	
	
			
		
		
	
	
			64 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			TeX
		
	
	
	
	
	
\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).
 | 
						|
 | 
						|
Example of using it:
 | 
						|
 | 
						|
\begin{verbatim}
 | 
						|
void Set Foo()
 | 
						|
{
 | 
						|
    // 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}.
 | 
						|
 | 
						|
\wxheading{Derived from}
 | 
						|
 | 
						|
None.
 | 
						|
 | 
						|
\wxheading{Include files}
 | 
						|
 | 
						|
<wx/thread.h>
 | 
						|
 | 
						|
\wxheading{See also}
 | 
						|
 | 
						|
\helpref{wxCriticalSection}{wxcriticalsection}, 
 | 
						|
\helpref{wxMutexLocker}{wxmutexlocker}
 | 
						|
 | 
						|
\latexignore{\rtfignore{\wxheading{Members}}}
 | 
						|
 | 
						|
\membersection{wxCriticalSectionLocker::wxCriticalSectionLocker}\label{wxcriticalsectionlockerctor}
 | 
						|
 | 
						|
\func{}{wxCriticalSectionLocker}{\param{wxCriticalSection\& }{criticalsection}}
 | 
						|
 | 
						|
Constructs a wxCriticalSectionLocker object associated with given
 | 
						|
{\it criticalsection} and enters it.
 | 
						|
 | 
						|
\membersection{wxCriticalSectionLocker::\destruct{wxCriticalSectionLocker}}\label{wxcriticalsectionlockerdtor}
 | 
						|
 | 
						|
\func{}{\destruct{wxCriticalSectionLocker}}{\void}
 | 
						|
 | 
						|
Destructor leaves the critical section.
 | 
						|
 |