|
CPN
Computational Process Networks
|
#include <ReentrantLock.h>
Collaboration diagram for Sync::StatusHandler< Status_t >:Public Member Functions | |
| StatusHandler (Status_t initialStatus) | |
| ~StatusHandler () | |
| void | Post (Status_t newStatus) |
| Status_t | Get () const |
| bool | CompareAndPost (Status_t oldStatus, Status_t newStatus) |
| template<class Comparator > | |
| bool | CompareAndPost (Status_t oldStatus, Status_t newStatus, Comparator comp) |
| Status_t | CompareAndWait (Status_t oldStatus) const |
| template<class Comparator > | |
| Status_t | CompareAndWait (Status_t oldStatus, Comparator comp) const |
| Status_t | ComparePostAndWait (Status_t oldStatus, Status_t newStatus) |
| template<class Comparator > | |
| Status_t | ComparePostAndWait (Status_t oldStatus, Status_t newStatus, Comparator comp) |
| void | CompareWaitAndPost (Status_t theStatus, Status_t newStatus) |
Private Attributes | |
| Status_t | status |
| pthread_mutex_t | lock |
| pthread_cond_t | cond |
The StatusHandler template is meant to be used to simplify having a status variable in a multi threaded application. The StatusHandler can be used much like an atomic variable or a blocking queue with size 1.
Future improvements to this might be to use actual atomic compare and set primatives for these operations rather than a lock and condition.
The ReentrantLock passed in the constructor must be valid for the lifetime of this object and you must hold the lock when calling any of the wait functions.
Definition at line 39 of file ReentrantLock.h.
|
inline |
Definition at line 60 of file StatusHandler.h.
|
inline |
Definition at line 66 of file StatusHandler.h.
|
inline |
Post a change in status only if the current status is oldStatus.
| oldStatus | the status to compare to |
| newStatus | the new status to change to |
Definition at line 96 of file StatusHandler.h.
Referenced by CPN::Kernel::EntryPoint(), and CPN::Kernel::NotifyTerminate().
Here is the caller graph for this function:
|
inline |
Definition at line 107 of file StatusHandler.h.
|
inline |
This function waits until the status is different than oldStatus.
| oldStatus | the status to compare to the current status |
Definition at line 124 of file StatusHandler.h.
Referenced by CPN::Kernel::Kernel(), and CPN::Kernel::Wait().
Here is the caller graph for this function:
|
inline |
Definition at line 131 of file StatusHandler.h.
|
inline |
This function compares status to oldStatus and if the same sets the status to newStatus. Then waits until the status is different than newStatus.
| oldStatus | the status to compare |
| newStatus | the status to set the status to |
Definition at line 145 of file StatusHandler.h.
|
inline |
Definition at line 156 of file StatusHandler.h.
|
inline |
Wait for the status to become theStatus then set to newStatus.
Definition at line 169 of file StatusHandler.h.
|
inline |
Definition at line 84 of file StatusHandler.h.
Referenced by CPN::Kernel::EntryPoint(), CPN::Kernel::InternalCreateNode(), CPN::Kernel::LogState(), CPN::Kernel::NodeTerminated(), and CPN::Kernel::Wait().
Here is the caller graph for this function:
|
inline |
Post a change in status.
| newStatus | the new status |
Definition at line 75 of file StatusHandler.h.
Referenced by CPN::Kernel::EntryPoint().
Here is the caller graph for this function:
|
mutableprivate |
Definition at line 179 of file StatusHandler.h.
Referenced by Sync::StatusHandler< KernelStatus_t >::CompareAndPost(), Sync::StatusHandler< KernelStatus_t >::CompareAndWait(), Sync::StatusHandler< KernelStatus_t >::ComparePostAndWait(), Sync::StatusHandler< KernelStatus_t >::CompareWaitAndPost(), Sync::StatusHandler< KernelStatus_t >::Post(), Sync::StatusHandler< KernelStatus_t >::StatusHandler(), and Sync::StatusHandler< KernelStatus_t >::~StatusHandler().
|
mutableprivate |
Definition at line 178 of file StatusHandler.h.
Referenced by Sync::StatusHandler< KernelStatus_t >::CompareAndPost(), Sync::StatusHandler< KernelStatus_t >::CompareAndWait(), Sync::StatusHandler< KernelStatus_t >::ComparePostAndWait(), Sync::StatusHandler< KernelStatus_t >::CompareWaitAndPost(), Sync::StatusHandler< KernelStatus_t >::Get(), Sync::StatusHandler< KernelStatus_t >::Post(), Sync::StatusHandler< KernelStatus_t >::StatusHandler(), and Sync::StatusHandler< KernelStatus_t >::~StatusHandler().
|
private |
Definition at line 177 of file StatusHandler.h.
Referenced by Sync::StatusHandler< KernelStatus_t >::CompareAndPost(), Sync::StatusHandler< KernelStatus_t >::CompareAndWait(), Sync::StatusHandler< KernelStatus_t >::ComparePostAndWait(), Sync::StatusHandler< KernelStatus_t >::CompareWaitAndPost(), Sync::StatusHandler< KernelStatus_t >::Get(), and Sync::StatusHandler< KernelStatus_t >::Post().
1.8.5