1#ifndef _DRAMA2_THREADUFACE_INC
2#define _DRAMA2_THREADUFACE_INC
35#include <condition_variable>
66 class TUface :
public TMessHandler,
public RunDramaExitNotifier {
74 std::weak_ptr<Task> _theTask;
81 static std::set<TUface *> _loggerOnly;
137 virtual bool JoinThreads(std::chrono::steady_clock::time_point
until)
override;
145 std::shared_ptr<Task>
GetTask()
const override {
146 return std::shared_ptr<Task>(_theTask);
196 template<
typename...
Types>
197#ifndef RUNNING_DOXYGEN
198 D2_FMT_DEPRECATED(
"Replace MessageUser() by MessageUserF(). See MessageUserF() page for details.")
206 std::stringstream
sstrm;
229 template<
typename...
Args>
299 _loggerOnly.insert(
this);
320 WaitEventMapType _waitEventMap;
323 void MessageReceived();
324 void ProcessSubsidiaryMessage();
328 static void UfaceMessageHandler(
StatusType *);
334 void OrphanOutstandingEvents();
342 _entryInfo.SetFromDits();
359 WaitEventDetails *FindWaitEventDetails(std::thread::id)
371 std::thread::id
threadId(std::this_thread::get_id());
390 *eventInfo =
details.eventInfo;
void SetFromDits()
Grab the information of interest from DITS.
Definition entryinfo.hh:123
The EntryInfo class is used to access details about a DRAMA message event (and entry to an action).
Definition entryinfo.hh:106
A Class which provides access to DRAMA's message sending facilities.
Definition path.hh:689
Class used to arrange for notifications when the RunDrama exits.
Definition task.hh:393
std::recursive_timed_mutex mutexType
Defines the type of our mutex.
Definition task.hh:466
This interface class must be implemented by classes which have threads waiting for messages.
Definition thread.hh:308
static bool ___LoggerOnlyUFACEItem(TUface *pnt)
Indicate if logger only UFACE item created when Logger::RegisterThreadNoDramaCtx() was invoked (Actua...
void MessageUser(const std::string &text) const override
Use DRAMA to send a message to the user.
void WaitForTransactionFinish(const WaitEventData &details, TransEvtInfo *const eventInfo, sds::IdPtr *const arg)
The wait for transaction operation has finished - tidy up.
Definition threaduface.hh:411
std::shared_ptr< Task > GetTask() const override
Get a reference to the DRAMA task we are part of.
Definition threaduface.hh:172
void SetupWaitEvent(DitsTransIdType tid, drama::Path *pathObj) override
Sets up a wait event for this thread.
virtual const EntryInfo & GetEntry() const
Return the entry details.
Definition threaduface.hh:308
TUface(std::weak_ptr< Task > dramaTask, const std::string &logThreadName="TUface::TUface")
Create a DRAMA action/message handler object which runs a thread when the Obey message is received.
Task::mutexType & Lock() const override
Reference the DRAMA Task lock.
virtual ~TUface()
TUface destructor.
void MessageUser(const char *format, Types... args)
Use DRAMA to send a message to the user - safe format.
Definition threaduface.hh:227
void MessageUserF(const fmt::format_string< Args... > fmt, Args &&... args)
Use DRAMA to send a message to the user - format using fmt::format.
Definition threaduface.hh:257
virtual bool JoinThreads(std::chrono::steady_clock::time_point until) override
Invoked when the drama::task::RunDrama() loop exits.
void ClearWait(bool complete) override
Clear the thread' waiting flag in _waitEventMap.
WaitEventDetails * WaitForTransactionStart()
Initiate waiting for a transaction and return a pointer to the item the wait event details.
Definition threaduface.hh:397
virtual int RunDramaHasExited() override
Invoked when the drama::task::RunDrama() loop exits.
Dits___CurActType GetMessageContext() const override
Get the DRAMA Context associated with the UFACE event.
void ___SetLoggerOnlyUFACEItem()
Indicate that this UFACE item is for a thread which invoked Logger::RegisterThreadNoDramaCtx() withou...
Definition threaduface.hh:320
void GrabEntryInfo()
Fetch the DRAMA Entry information.
Definition threaduface.hh:368
A class which allows threads running in a User Interface or similar environments to send DRAMA messag...
Definition threaduface.hh:93
DRAMA 2 include file - Message Handler class definition.
std::shared_ptr< Id > IdPtr
A shared pointer for sds::Id items.
Definition sds.hh:3613
void SignalDramaToExit(std::weak_ptr< Task > dramaTask, StatusType exitStatus=STATUS__OK)
Signal to DRAMA that this task should exit.
void CreateRunDramaTask()
Create and run a DRAMA task, with standard exception handling.
Definition task.hh:1339
void SafePrintf(std::ostream &ostream, const char *str)
Safe formatted write to a stream.
The drama namespace contains all the classes, types etc of the DRAMA 2 implementation.
Definition drama.hh:99
Structure is used to store details about a DRAMA reschedule message relating to a transaction,...
Definition task.hh:134
DRAMA 2 include file - Code common to DRAMA 2 features supporting threading.