wxcriticalsectiona critical section object is used for exactly the same purpose as mutexes. the only difference is that under windows platform 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 wxcriticalsectionlocker class whenever possible instead of directly using wxcriticalsection for the same reasons wxmutexlocker is preferrable to wxmutex - please see wxmutex for an example. derived from none. include files <wx/thread.h> see also wxthread, wxcondition, wxcriticalsectionlocker members
wxcriticalsection::wxcriticalsection
wxcriticalsection::wxcriticalsectionwxcriticalsection() default constructor initializes critical section object.
wxcriticalsection::~wxcriticalsection~wxcriticalsection() destructor frees the resources.
wxcriticalsection::entervoid enter() 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.
wxcriticalsection::leavevoid leave() leave the critical section allowing other threads use the global data protected by it. there is no error return for this function.
|