AAO DRAMA/DRAMA2 C++ Interface
DRAMA C++11 and later interface
|
A class which implements a DRAMA Action with runs a thread.
Interface only. Users must sub-class and implement ActionThread(), which is invoked in a new thread created when the action is invoked.
Many of the methods of drama::MessageHandler are re-implemented to work within a thread, such as MessageUser and SendTrigger.
Methods are also available to wait for kick messages to be received. Threaded actions are required if you want to send messages to other DRAMA tasks.
These objects can then be supplied to the drama::Task::Add() methods
#include "threadaction.hh"
Public Member Functions | |
TAction (const TAction &source)=delete | |
Copy constructor - deleted. | |
TAction (std::weak_ptr< Task > dramaTask, double timeout=0) | |
Create a DRAMA action/message handler object which runs a thread when the Obey message is received. | |
virtual | ~TAction () |
TAction destructor. | |
void | AbortMessageWaits (StatusType status) |
Tells any thread waiting for messages to abort the wait event. | |
void | ClearExitOnCompletion () |
Clear exit on completion. | |
bool | DoWaitForKick (WaitEventDetails *waitEvent, sds::IdPtr *const arg=nullptr) |
Wait for a kick event with the waitEvent details given. | |
std::string | GetActionName () const |
Return the name of the action this thread is implementing. | |
virtual const EntryInfo & | GetEntry () |
Return the action entry details. | |
unsigned | GetKickCount () const |
Returns the number of times this action has been kicked since started or the last reset of the count. | |
Dits___CurActType | GetMessageContext () const override |
Get the DRAMA Context associated with the action event. | |
std::shared_ptr< Task > | GetTask () const override |
Get a reference to the DRAMA task we are part of. | |
double | GetTimeout () const |
Return the current action timeout. | |
Task::mutexType & | Lock () const override |
Get a reference the DRAMA Task lock. | |
template<typename... Types> | |
void | MessageUser (const char *format, Types... args) |
Use DRAMA to send a message to the user - safe format. | |
void | MessageUser (const std::string &text) const override |
Use DRAMA to send a message to the user. | |
TAction & | operator= (const TAction &rhs)=delete |
Assignment operator - deleted. | |
void | PutKickHandler (MessageHandlerPtr obj) override final |
We cannot change the kick handler in a threaded action, it does not make sense. | |
virtual void | PutKickHandler (MessageReceiveFunction func) |
Put a message handler function for the next Kick event. | |
void | PutObeyHandler (MessageHandlerPtr obj) override final |
We cannot change the obey handler in a threaded action, it does not make sense as the action never reschedules (as viewed by the user code). | |
virtual void | PutObeyHandler (MessageReceiveFunction func) |
Put a message handler function for the next Obey reschedule event. | |
void | ResetKickCount () |
Returns a shared pointer to the last kick message argument. | |
virtual const sds::PrintObjectCR & | SdsListToUser () const override |
Get a reference to an SDS printer object which can be used to list an SDS object using MessageUser. | |
void | SendBulkTrigger (BulkData *arg, DitsTransIdType *transId, bool isSds, unsigned notifyBytes=1024 *1024) |
Send a bulk data trigger message to the parent action. | |
void | SendBulkTrigger (BulkDataSds *arg, DitsTransIdType *transId, unsigned notifyBytes=1024 *1024) |
Send a bulk data trigger message to the parent action. | |
void | SendTrigger (const sds::Id &arg) const |
Send a trigger message to the parent action. | |
void | SetAction (Action *action) |
Invoked when the ActionHandler is associated with a DRAMA action entry (object type Action). | |
void | SetExitOnCompletion () |
Set exit on completion. | |
void | SetReturnArg (const sds::Id &arg, bool copy=true) |
Set the argument to be sent as part of the action completion message. | |
void | SetReturnArg (sds::Id *arg) |
Set the argument to be sent as part of the action completion message. | |
void | SetTimeout (double newTimeout) |
Set a new timeout. | |
void | SetupWaitEvent (DitsTransIdType tid, drama::Path *pathObj) override |
Sets up a wait event for this thread. | |
WaitEventDetails * | SetupWaitForKick () |
Set up to wait for a kick message. | |
template<class Clock , class Duration > | |
bool | WaitEventTimeoutAt (EntryCode *event, const std::chrono::time_point< Clock, Duration > &abs_time, sds::IdPtr *const arg=0) |
Block the current thread until a signal/kick for the action is received or until a given time. | |
void | WaitForEvent (EntryCode *event, sds::IdPtr *const arg=nullptr) |
Block the current thread until a kick/signal message for the action is received. | |
template<class Rep , class Period > | |
bool | WaitForEventTimeoutIn (EntryCode *event, const std::chrono::duration< Rep, Period > &rel_time, sds::IdPtr *const arg=0) |
Block the current thread until a signal/kick for the action is received or a duration has passed. | |
bool | WaitForEventTimeoutIn (EntryCode *event, unsigned seconds, sds::IdPtr *const arg=0) |
Block the current thread until a signal/kick for the action is received or a duration in seconds has passed. | |
void | WaitForKick (sds::IdPtr *const arg=nullptr) |
Block the current thread until a kick for the action is received. | |
template<class Rep , class Period > | |
bool | WaitForKickTimeoutIn (const std::chrono::duration< Rep, Period > &rel_time, sds::IdPtr *const arg=0) |
Block the current thread until a kick for the action is received or a duration has passed. | |
bool | WaitForKickTimeoutIn (unsigned seconds, sds::IdPtr *const arg=0) |
Block the current thread until a kick for the action is received or a duration in seconds has passed. | |
virtual void | WaitForTransaction (std::weak_ptr< Task > theTask, TransEvtInfo *const eventInfo, TransEvtProcessor *const eventProcessor, sds::IdPtr *const arg=nullptr) |
Block the current thread until a message for the transaction specified to SetupWaitEvent() occurs. | |
virtual bool | WaitForTransactionUntil (std::weak_ptr< Task > theTask, TransEvtInfo *const eventInfo, TransEvtProcessor *const eventProcessor, const std::chrono::steady_clock::time_point &until, sds::IdPtr *const arg=nullptr) |
Block the current thread until a message for the transaction specified to SetupWaitEvent() occurs or until a certain time has passed. | |
template<class Clock , class Duration > | |
bool | WaitKickForTimeoutAt (const std::chrono::time_point< Clock, Duration > &abs_time, sds::IdPtr *const arg=0) |
Block the current thread until a kick for the action is received or until a given time. | |
Protected Member Functions | |
virtual void | ActionEnd (bool taskExiting, StatusType actionEndStatus) |
Method Invoked when the action completes. | |
void | GrabEntryInfo () |
Fetch the DRAMA Entry information. | |
Click here for the DRAMA home page and here for the AAO home page.
For more information, contact tony.farrell@mq.edu.au
Generated on Thu Dec 12 2024 23:07:36 for AAO DRAMA/DRAMA2 C++ Interface by 1.9.8