]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/critsect.tex
* Stream doc update.
[wxWidgets.git] / docs / latex / wx / critsect.tex
1 \section{\class{wxCriticalSection}}\label{wxcriticalsection}
2
3 A critical section object is used exactly for the same purpose as
4 \helpref{mutexes}{wxMutex}. The only difference is that under Windows platform
5 critical sections are only visible inside one process, while mutexes may be
6 shared between processes, so using critical sections is slightly more
7 efficient. The terminology is also slightly different: mutex may be locked (or
8 acquired) and unlocked (or released) while critical section is entered and left
9 by the program.
10
11 Finally, you should try to use
12 \helpref{wxCriticalSectionLocker}{wxcriticalsectionlocker} class whenever
13 possible instead of directly using wxCriticalSection for the same reasons
14 \helpref{wxMutexLocker}{wxmutexlocker} is preferrable to
15 \helpref{wxMutex}{wxmutex} - please see wxMutex for an example.
16
17 \wxheading{Derived from}
18
19 None.
20
21 \wxheading{See also}
22
23 \helpref{wxThread}{wxthread}, \helpref{wxCondition}{wxcondition},
24 \helpref{wxMutexLocker}{wxmutexlocker}, \helpref{wxCriticalSection}{wxcriticalsection}
25
26 \latexignore{\rtfignore{\wxheading{Members}}}
27
28 \membersection{wxCriticalSection::wxCriticalSection}\label{wxcriticalsectionctor}
29
30 \func{}{wxCriticalSection}{\void}
31
32 Default constructor initializes critical section object.
33
34 \membersection{wxCriticalSection::\destruct{wxCriticalSection}}\label{wxcriticalsectiondtor}
35
36 \func{}{\destruct{wxCriticalSection}}{\void}
37
38 Destructor frees the ressources.
39
40 \membersection{wxCriticalSection::Enter}\label{wxcriticalsectionenter}
41
42 \func{void }{Enter}{\void}
43
44 Enter the critical section (same as locking a mutex). There is no error return
45 for this function. After entering the critical section protecting some global
46 data the thread running in critical section may safely use/modify it.
47
48 \membersection{wxCriticalSection::Leave}\label{wxcriticalsectionleave}
49
50 \func{void }{Leave}{\void}
51
52 Leave the critical section allowing other threads use the global data protected
53 by it. There is no error return for this function.
54