ACE notes (7) -ACE monomer instance, primitive, lock, condition variable
First introduce the concept of the ACE monomer instance so that the monomer instance is a static global object, its lifecycle is managed by the ACE mechanism, so it is absolutely not to call the system underlayer in the main function, and exit the main function. Otherwise, these monomer instances will not be released, default, ACE generates some common or special monomer instances when the program starts.
You can also generate your own monomer class by template technology, as follows: #include "ace / auto_event.h" #include "ace / singleton.h" #include "ace / thread_manager.h"
TYPEDEF ACE_SIINGLETON
Of course, this is understood to have the compiler templates need to add the following code to help understand the compiler: #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Singleton
Lock and conditional variables: Lock ensures that resources are only one thread operating condition variables in a certain time, which is usually required to use the common class: ACE_THREAD_MUTEX class: acquire: get the right to lock, if Specified time is not available, return -1 Release method: Release lock Use rights acquire_read () get the lock read power ACQUIRE_WRITE () get the write rights ACE_THREAD_MUTEX class ACE_CONDITION_THREAD_MUTEX class ACE_CONDITION_THREAD_MUTEX (Lock): Construct a lock condition variable wait () Waiting condition Established Signal () Send condition to set up a signal