AAO DRAMA/DRAMA2 C++ Interface
|
An object used to obtain notifications of kicks.
A KickNotifier object is used to allow blocking threaded action code to be notified if a Kick message is received for the action. This must be executed from a threaded action or a child thread of such an action.
The constructor will create a child thread which will wait for the DRAMA action (specified to the constructor) to be kicked. When kicked, the Kicked() method is invoked (in the context of the child thread). User code can sub-class and override Kicked() as required, or poll via the WasKicked() method to determine if the action has been kicked.
The destructor will destroy the child thread.
#include "threadaction.hh"
Public Member Functions | |
KickNotifier (TAction *action) | |
KickNotifier constructor. More... | |
KickNotifier (const KickNotifier &source)=delete | |
Copy constructor - deleted. More... | |
virtual | ~KickNotifier () |
Destructor. More... | |
virtual bool | Kicked (const sds::Id &arg) |
Method invoked when a Kick occurs. More... | |
KickNotifier & | operator= (const KickNotifier &rhs)=delete |
Assignment operator - deleted. More... | |
bool | WasKicked () |
Indicates if the action was kicked. More... | |
drama::thread::KickNotifier::KickNotifier | ( | TAction * | action | ) |
KickNotifier constructor.
Constructs a KickNotifier object, used to allow blocking action code to be notified if a Kick is received by the action. This must be executed from a threaded action or a child thread of such an action.
User code should ensure an object of this type or a sub-class is constructed before the blocking code, and destroyed after it is finished.
The constructor will create a thread that will wait for notification from DRAMA that the action has been kicked. When a kick occurs, the Kicked() method with will be invoked. A sub-class code can override the Kicked() method to do something appropriate to cause the blocked code to unblock.
Alternatively, user code can invoke the WasKicked() method to determine if a kick has occurred.
|
virtual |
Destructor.
Ensure the thread is unblocked and then join it.
|
delete |
Copy constructor - deleted.
|
virtual |
Method invoked when a Kick occurs.
User code can override this in a sub-class to arrange to be notified when a kick occurs.
A sub-class author must determine the sensible thing to do when this is invoked, which will depend on why the action code is blocked. They may need to cancel I/O or break out of a CPU intensive operation. The most dramatic approach would be to use setjmp() and longjmp(), but in that case care must be taken over the management of resources (i.e. don't jump such as to avoid running destructors, ensure the KickNotifier destructor is run.).
arg | Argument to the kick, if any. |
|
delete |
Assignment operator - deleted.
|
inline |
Indicates if the action was kicked.
References drama::thread::TAction::GetTask().
Click here for the DRAMA home page and here for the AAO home page.
For more information, contact tjf@aao.gov.au Generated on Mon Feb 22 2016 15:57:53 for AAO DRAMA/DRAMA2 C++ Interface by