File cmb_condition.h
↰ Parent directory (include)
A condition variable class that allows a process to wait for an arbitrary condition to become true and be reactivated at that point. It does not assign any resource, just signals that the condition is fulfilled. The application provides the demand predicate function to be evaluated.
Definition (include/cmb_condition.h)
Detailed Description
Classes like cmb_resource or cmb_buffer use pre-packaged demand functions for simple conditions (such as “buffer level greater than zero”) and update the resource state accordingly (such as decrementing the buffer level by the correct amount). When using the cmb_condition instead, the user application provides the demand predicate function and takes the correct action when a waiting process is reactivated. The demand predicate function can even be different for each waiting process. It will be evaluated for each waiting process separately.
When signaled, the condition variable evaluates the predicate function for all waiting processes and reactivates all that evaluate to true. The condition variable cannot know what happens next, so it is the calling processes’ own responsibility to recheck the condition and wait again if it no longer is satisfied. This is different from classes like cmb_resource, where we can assign the resource to the acquiring process and know that no other processes need to be awakened.
Recall that in a discrete event simulation, the state can only change at an event. By registering itself as an observer at some other resource guard, the condition variable will receive a signal whenever something has changed, can re-evaluate the demand functions for its waiting processes, and reactivate as justified.
Includes
cmb_resourceguard.h(File cmb_resourceguard.h)cmi_resourcebase.h