1999-01-02 18:02:30 -05:00
|
|
|
\section{\class{wxCriticalSection}}\label{wxcriticalsection}
|
|
|
|
|
2002-12-04 09:11:26 -05:00
|
|
|
A critical section object is used for exactly the same purpose as
|
2001-05-24 17:35:34 -04:00
|
|
|
\helpref{mutexes}{wxmutex}. The only difference is that under Windows platform
|
1999-01-02 18:02:30 -05:00
|
|
|
critical sections are only visible inside one process, while mutexes may be
|
|
|
|
shared between processes, so using critical sections is slightly more
|
|
|
|
efficient. The terminology is also slightly different: mutex may be locked (or
|
|
|
|
acquired) and unlocked (or released) while critical section is entered and left
|
|
|
|
by the program.
|
|
|
|
|
|
|
|
Finally, you should try to use
|
|
|
|
\helpref{wxCriticalSectionLocker}{wxcriticalsectionlocker} class whenever
|
|
|
|
possible instead of directly using wxCriticalSection for the same reasons
|
|
|
|
\helpref{wxMutexLocker}{wxmutexlocker} is preferrable to
|
|
|
|
\helpref{wxMutex}{wxmutex} - please see wxMutex for an example.
|
|
|
|
|
|
|
|
\wxheading{Derived from}
|
|
|
|
|
|
|
|
None.
|
|
|
|
|
1999-02-15 15:41:29 -05:00
|
|
|
\wxheading{Include files}
|
|
|
|
|
|
|
|
<wx/thread.h>
|
|
|
|
|
1999-01-02 18:02:30 -05:00
|
|
|
\wxheading{See also}
|
|
|
|
|
1999-01-17 14:25:06 -05:00
|
|
|
\helpref{wxThread}{wxthread}, \helpref{wxCondition}{wxcondition},
|
1999-01-02 18:02:30 -05:00
|
|
|
\helpref{wxMutexLocker}{wxmutexlocker}, \helpref{wxCriticalSection}{wxcriticalsection}
|
|
|
|
|
|
|
|
\latexignore{\rtfignore{\wxheading{Members}}}
|
|
|
|
|
|
|
|
\membersection{wxCriticalSection::wxCriticalSection}\label{wxcriticalsectionctor}
|
1999-01-17 14:25:06 -05:00
|
|
|
|
1999-01-02 18:02:30 -05:00
|
|
|
\func{}{wxCriticalSection}{\void}
|
|
|
|
|
|
|
|
Default constructor initializes critical section object.
|
|
|
|
|
|
|
|
\membersection{wxCriticalSection::\destruct{wxCriticalSection}}\label{wxcriticalsectiondtor}
|
1999-01-17 14:25:06 -05:00
|
|
|
|
1999-01-02 18:02:30 -05:00
|
|
|
\func{}{\destruct{wxCriticalSection}}{\void}
|
|
|
|
|
2002-06-07 16:15:28 -04:00
|
|
|
Destructor frees the resources.
|
1999-01-02 18:02:30 -05:00
|
|
|
|
|
|
|
\membersection{wxCriticalSection::Enter}\label{wxcriticalsectionenter}
|
1999-01-17 14:25:06 -05:00
|
|
|
|
1999-01-02 18:02:30 -05:00
|
|
|
\func{void }{Enter}{\void}
|
|
|
|
|
|
|
|
Enter the critical section (same as locking a mutex). There is no error return
|
|
|
|
for this function. After entering the critical section protecting some global
|
|
|
|
data the thread running in critical section may safely use/modify it.
|
|
|
|
|
|
|
|
\membersection{wxCriticalSection::Leave}\label{wxcriticalsectionleave}
|
1999-01-17 14:25:06 -05:00
|
|
|
|
1999-01-02 18:02:30 -05:00
|
|
|
\func{void }{Leave}{\void}
|
|
|
|
|
|
|
|
Leave the critical section allowing other threads use the global data protected
|
|
|
|
by it. There is no error return for this function.
|
1999-01-17 14:25:06 -05:00
|
|
|
|