User manual

130
C++ wrappers to work with critical section
The basic interface of critical section is defined in abstract class
chapi_critical_section_interface.
Here is the list of public members:
virtual bool try_enter() = 0;
Abstract method attempts to enter a critical section without blocking. If the call is
successful, the calling thread takes ownership of the critical section and method return
“true”, else return value shell be equal “false”.
virtual void enter() = 0;
Abstract method waits for ownership of the specified critical section object. The function
returns when the calling thread is granted ownership.
virtual void leave() = 0;
Abstract method releases ownership of the specified critical section object.
Firts derived class from
chapi_critical_section_interface
is
chapi_stub_critical_section.
It is a stub class. All method will be execute sucsesful
witout waiting other threads.
chapi_mutex
implements
chapi_critical_section_interface
and for synchronization it
uses mutex. if the critical section is unavailable, the calling thread execute wait operation
on a semaphore associated with the critical section.
chapi_spinlock
implements
chapi_critical_section_interface
and for synchronization
uses spinlock. if the critical section is unavailable, the calling thread spin before
performing a wait operation on a semaphore associated with the critical section.
C++ wrappers to work with threads
chapi_task
class provide C++ wpapped to work with threads. Here is the list of public
members:
static chapi_handle_t create(chapi_proc_t (stdcall * task_body)(void *task_arg),
void * task_arg);