]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/crtslock.tex
Patches-1851591 ] dataview sample is crashing (under MSW)
[wxWidgets.git] / docs / latex / wx / crtslock.tex
1 \section{\class{wxCriticalSectionLocker}}\label{wxcriticalsectionlocker}
2
3 This is a small helper class to be used with \helpref{wxCriticalSection}{wxcriticalsection}
4 objects. A wxCriticalSectionLocker enters the critical section in the
5 constructor and leaves it in the destructor making it much more difficult to
6 forget to leave a critical section (which, in general, will lead to serious
7 and difficult to debug problems).
8
9 Example of using it:
10
11 \begin{verbatim}
12 void Set Foo()
13 {
14 // gs_critSect is some (global) critical section guarding access to the
15 // object "foo"
16 wxCriticalSectionLocker locker(gs_critSect);
17
18 if ( ... )
19 {
20 // do something
21 ...
22
23 return;
24 }
25
26 // do something else
27 ...
28
29 return;
30 }
31 \end{verbatim}
32
33 Without wxCriticalSectionLocker, you would need to remember to manually leave
34 the critical section before each {\tt return}.
35
36 \wxheading{Derived from}
37
38 None.
39
40 \wxheading{Include files}
41
42 <wx/thread.h>
43
44 \wxheading{Library}
45
46 \helpref{wxBase}{librarieslist}
47
48 \wxheading{See also}
49
50 \helpref{wxCriticalSection}{wxcriticalsection},
51 \helpref{wxMutexLocker}{wxmutexlocker}
52
53 \latexignore{\rtfignore{\wxheading{Members}}}
54
55 \membersection{wxCriticalSectionLocker::wxCriticalSectionLocker}\label{wxcriticalsectionlockerctor}
56
57 \func{}{wxCriticalSectionLocker}{\param{wxCriticalSection\& }{criticalsection}}
58
59 Constructs a wxCriticalSectionLocker object associated with given
60 {\it criticalsection} and enters it.
61
62 \membersection{wxCriticalSectionLocker::\destruct{wxCriticalSectionLocker}}\label{wxcriticalsectionlockerdtor}
63
64 \func{}{\destruct{wxCriticalSectionLocker}}{\void}
65
66 Destructor leaves the critical section.
67