]>
Commit | Line | Data |
---|---|---|
6e6110ee VZ |
1 | \section{\class{wxCriticalSection}}\label{wxcriticalsection} |
2 | ||
36edded9 | 3 | A critical section object is used for the same exactly purpose as |
520d1936 | 4 | \helpref{mutexes}{wxmutex}. The only difference is that under Windows platform |
6e6110ee VZ |
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 | ||
954b8ae6 JS |
21 | \wxheading{Include files} |
22 | ||
23 | <wx/thread.h> | |
24 | ||
6e6110ee VZ |
25 | \wxheading{See also} |
26 | ||
b82827dd | 27 | \helpref{wxThread}{wxthread}, \helpref{wxCondition}{wxcondition}, |
6e6110ee VZ |
28 | \helpref{wxMutexLocker}{wxmutexlocker}, \helpref{wxCriticalSection}{wxcriticalsection} |
29 | ||
30 | \latexignore{\rtfignore{\wxheading{Members}}} | |
31 | ||
32 | \membersection{wxCriticalSection::wxCriticalSection}\label{wxcriticalsectionctor} | |
b82827dd | 33 | |
6e6110ee VZ |
34 | \func{}{wxCriticalSection}{\void} |
35 | ||
36 | Default constructor initializes critical section object. | |
37 | ||
38 | \membersection{wxCriticalSection::\destruct{wxCriticalSection}}\label{wxcriticalsectiondtor} | |
b82827dd | 39 | |
6e6110ee VZ |
40 | \func{}{\destruct{wxCriticalSection}}{\void} |
41 | ||
2edb0bde | 42 | Destructor frees the resources. |
6e6110ee VZ |
43 | |
44 | \membersection{wxCriticalSection::Enter}\label{wxcriticalsectionenter} | |
b82827dd | 45 | |
6e6110ee VZ |
46 | \func{void }{Enter}{\void} |
47 | ||
48 | Enter the critical section (same as locking a mutex). There is no error return | |
49 | for this function. After entering the critical section protecting some global | |
50 | data the thread running in critical section may safely use/modify it. | |
51 | ||
52 | \membersection{wxCriticalSection::Leave}\label{wxcriticalsectionleave} | |
b82827dd | 53 | |
6e6110ee VZ |
54 | \func{void }{Leave}{\void} |
55 | ||
56 | Leave the critical section allowing other threads use the global data protected | |
57 | by it. There is no error return for this function. | |
b82827dd | 58 |