AAO DRAMA/DRAMA2 C++ Interface
DRAMA C++11 and later interface
path.hh
Go to the documentation of this file.
1#ifndef _DRAMA2_PATH_INC
2#define _DRAMA2_PATH_INC
20/*
21 * History:
22 06-Mar-2014 - TJF - Original version. Starting from dcpppath.h
23 30-Sep-2016 - TJF - Start of history after development.
24 Add MonForwardEventHandler class used as event
25 handler for monitors, main point is the triggers
26 don't cause exceptions.
27 Don't throw exceptions when messages return bad
28 status, the event handlers can do that, otherwise
29 event handlers cannot stop such errors occurring.
30 Add Two new overrides of MonitorForward().
31 30-Sep-2016 - TJF - Add SpawnKickArg() and SpawnKickArgUpdate() static
32 methods.
33
34
35
36 * The above ID is for Doxygen, this one has the format ACMM is looking for.
37 * "@(#) $Id$"
38 */
39#include "drama.hh"
40#include "DitsInteraction.h"
41#include "DitsFix.h"
42#include "DitsBulk.h"
43#include <drama/thread.hh>
44#include <set>
45#include <atomic>
46
47#include <initializer_list>
48
49namespace drama {
50
67 inline std::chrono::steady_clock::time_point CreateFutureTimepoint(double secs)
68 {
69 // Get now with the steady clock.
70 std::chrono::steady_clock::time_point until =
71 std::chrono::steady_clock::now();
72
73 // Duration with seconds in double.
74 std::chrono::duration<double> myDuration(secs);
75
76 /*
77 * When adding - we need the duration_cast as double has a higher
78 * resolution then steady_clock, since the later uses an integral type.
79 *
80 * But we get the highest resolution result we can wait on.
81 */
82 until += std::chrono::duration_cast<std::chrono::steady_clock::duration>(myDuration);
83
84 return until;
85
86 }
93 class Buffers {
94 private:
95 DitsPathInfoType _bufInfo;
96 public:
108 Buffers( long int MessageBytes = 800,
109 long int MaxMessages = 2,
110 long int ReplyBytes = 800,
111 long int MaxReplies = 10) {
112 _bufInfo.MessageBytes = MessageBytes;
113 _bufInfo.MaxMessages = MaxMessages;
114 _bufInfo.ReplyBytes = ReplyBytes;
115 _bufInfo.MaxReplies = MaxReplies;
116 }
123 Buffers ( const DitsPathInfoType & info) : _bufInfo(info) {};
126 operator const DitsPathInfoType * () const {
127 return &_bufInfo;
128 }
133 long int MessageBytes() const { return _bufInfo.MessageBytes; }
138 long int MaxMessages() const { return _bufInfo.MaxMessages; }
143 long int ReplyBytes() const { return _bufInfo.ReplyBytes; }
148 long int MaxReplies() const { return _bufInfo.MaxReplies; };
149 }; // class Buffers.
153 typedef std::vector<ErsMessageType> ErsMessageVector;
154
155
156
167 class MessageEventHandler : public thread::TransEvtProcessor {
168 private:
169 /*
170 * Converts argument to a MsgOut() message into call to MessageUser().
171 */
172 void MessageUserRaw(thread::ProcessInfo messInfo, const sds::IdPtr &arg);
173
174 /*
175 * Coverts argument to a Ers() message and calls ErrorReport().
176 */
177 virtual void ErrorReportRaw(thread::ProcessInfo messInfo,
178 const sds::IdPtr &arg);
179
181 public:
196 const TransEvtInfo & eventInfo,
197 const sds::IdPtr &arg) override final;
198
215 virtual void NewTransaction(DitsMsgType msgType, DitsTransIdType tid) override;
216
217
218
253 StatusType status, const sds::IdPtr &arg);
254
255
270 const sds::IdPtr &arg);
271
272
286
303 StatusType status, const sds::IdPtr &arg);
304
314
332 const std::string &task,
333 const std::string &message);
334
353 const std::string &task,
355
375 const sds::IdPtr &arg);
376
377
398 DitsBulkInfoType bulkInfo);
399
414
415 };
425 class MonForwardEventHandler : public MessageEventHandler {
426 public:
441 virtual void TriggerReceived(thread::ProcessInfo messInfo,
443 const sds::IdPtr &arg) override;
444
445 };
446
449 class GetPathEventHandler : public thread::TransEvtProcessor {
450 public:
470 virtual bool Process(thread::ProcessInfo messInfo,
471 const TransEvtInfo & eventInfo,
472 const sds::IdPtr &arg) override;
473
485 virtual void NewTransaction(DitsMsgType msgType, DitsTransIdType tid) override;
486 };
487
502 class IsRunningType : public drama::MessageEventHandler {
503 public:
507 enum class EventStatus {
508 NotStarted,
509 Running,
510 Failed,
511 Completed
512 };
517 EventStatus Get() const { return _status; };
518
524 std::string GetStr(EventStatus val) const;
525
530 std::string GetStr() const { return GetStr(_status); }
531
532
537 bool operator()() const {
538 if (_status == EventStatus::Running)
539 {
540 //std::cerr << "EventStatus true" << std::endl;
541 return true;
542 }
543 else
545 //std::cerr << "EventStatus false" << std::endl;
546 return false;
547 }
548 }
550 IsRunningType() {
552 }
553 protected:
562 _status = newVal;
563 }
565
566 private:
567 /* The variable we maintain. Use atomic since this intended for
568 * read/write from one thread, read from another
569 */
570 std::atomic<EventStatus> _status;
571
572 protected:
581
582 /* We won't override ThreadWaitAbort, what to do is unclear as the
583 * transaction remains running */
584
599 StatusType status) override;
619 const drama::sds::IdPtr &arg) override;
631 StatusType status) override;
632
633 }; // Class IsRunningType.
634
635
662 class Path {
663
664 private:
665
666 /*
667 * We need a static list of Path objects, so that we can handle
668 * DITS Disconnected events and translate them to Path objects to
669 * be notified.
670 *
671 * Note - I traditionally use a list here, but in fact, a std::set
672 * makes more sense. We define the type here, but use a
673 * static function to construct and access the object to avoid
674 * static initialization order issues.
675 */
676 typedef std::set<Path *> ObjectListType;
677 static ObjectListType &ObjectList();
678
679
680 /* Indicates if the disconnect handler has been enabled.*/
681 static bool _DisconnectEnabled;
682
683 /*
684 * The disconnect handler details when our disconnect handler
685 * was enabled.
686 */
687 static DitsDisConnectRoutineType _OrigDisconnect;
688 static DVOIDP _OrigDisconnectData;
690 /*
691 * Basic message even handler.
692 */
693 static MessageEventHandler _simpleEventProcessor;
694 static GetPathEventHandler _getPathEventProcessor;
695 static MonForwardEventHandler _simpleMonEventProcessor;
696 /*
697 * Pointer to the DRAMA task we are part of.
698 * (Note, in other examples, we make the pointer const, but
699 * if we do that here, we can't use the move assignment operator)
700 */
701 std::weak_ptr<Task> _theTask;
702
703
704 /* The path to the task, if state != INITIAL */
705 DitsPathType _path = nullptr;
706 /* The state of this task object (NOTIFY not yet supported */
707 enum class PathState { INITIAL, SELFINIT, PATHWAIT, LOADING,
708 ACTIVE, DIED, NOTIFY }
709 _state = PathState::INITIAL;
710 /* Buffer sizes */
711 Buffers _buffers;
712 /* Flags to the PathGet operation */
713 int _pathFlags = 0;
714 /* Task priority */
715 int _priority = 0;
716 /* Flags to the load command */
717 int _loadFlags = 0;
718 /* Set true to indicate the last GetPath loaded this task */
719 bool _loaded = false;
720 /* Do we log loads */
721 bool _logLoad = true;
722 /* The name of the task */
723 std::string _taskName;
724 /* The location of the task */
725 std::string _taskLocation;
726 /* The file to load the task from */
727 std::string _taskFile;
728 /* The requested process name */
729 std::string _process;
730 /* Argument to the load command */
731 std::string _argument;
732 /* Decode string */
733 std::string _decode;
734
735 unsigned _stackSize = 0;
736
737 /*
738 * Various internal routines.
739 */
740 /* Enable the disconnect handler, if not already enabled
741 * Can only be called if DitsAppInit() has been run, hence
742 * not from normally a constructor.
743 */
744 void EnableDisconnect();
745
746 /*
747 * Invoked by constructors to do common stuff.
748 */
749 void ConstructorHelper();
750
751
752 public: /* These two can be public */
753 /*
754 * Return a string (char *) version of a state enum. Used in
755 * logging and error messages.
756 */
757 const char *StateString(PathState state) const;
758 /*
759 * Return a string (char *) version of the current state. Used in
760 * logging and error messages.
761 */
762 const char *StateString() const {
763 return StateString(_state);
764 }
765 private:
766
767 /*
768 * Start the GetPath operation, returning the transaction id.
769 */
770 DitsTransIdType GetPathStart(thread::TMessHandler *action);
771
772 /*
773 * Load the task.
774 */
775 DitsTransIdType LoadTask(thread::TMessHandler *action);
776 /*
777 * A load (started by GetPathStart() has completed, process it
778 * and set the GetPath operation
779 */
780 DitsTransIdType LoadCompleteGetPath(
781 thread::TMessHandler *action,
783 const TransEvtInfo &eventInfo); // Transaction event details.
784
785 /*
786 * Complete the GetPath operation.
787 */
788 void GetPathComplete(
789 const TransEvtInfo &eventInfo); // Transaction event details.
790
791 /*
792 * Underlying send routine used by the various methods which send
793 * a DRAMA message.
794 *
795 * @param action A pointer to the threaded action which is
796 * executing this operation.
797 * @param type Message type.
798 * @param name Name of the action to start.
799 * @param argIn Argument to the action.
800 * @param eventProcessor An object to use to process events.
801 * All Send() does is to invoke the NewTransaction()
802 * method when it has sent the message.
803 *
804 * @return The DRAMA transaction ID of the message.
805 */
806 DitsTransIdType Send(
807 thread::TMessHandler *action,
809 const std::string & name,
810 int flags,
811 const sds::Id &arg,
812 MessageEventHandler * const eventProcessor);
813
814
815 /*
816 * Underlying send bulk routine used by the various methods which send
817 * a DRAMA message.
818 *
819 * @param action A pointer to the threaded action which is
820 * executing this operation.
821 * @param type Message type.
822 * @param name Name of the action to start.
823 * @param argIn The Bulk Data segment to be the argument to the
824 * obey message.
825 * @param isSds Does arg contain an SDS item? If true,
826 * the target task can access the item as an
827 * argument using using SDS in the normal way
828 * If false, the shared memory contains data in an
829 * application private format and DRAMA makes no attempt
830 * to interpret it.
831 * @param notifyBytes If non-zero, it indicates your action should
832 * be notified (using EntryCode::BulkTransferred
833 * entries) every time the specified number
834 * of bytes are transferred. Note the this effect
835 * is somewhat dependent on the target task
836 * behavior and you may only receive the final
837 * EntryCode::BulkDone message.
838 * @param eventProcessor An object to use to process events.
839 * All Send() does is to invoke the NewTransaction()
840 * method when it has sent the message.
841 *
842 * @return The DRAMA transaction ID of the message.
843 */
844 DitsTransIdType SendBulk(
845 thread::TMessHandler *action,
847 const std::string & name,
848 int flags,
849 BulkData *argIn,
850 bool isSds,
851 unsigned notifyBytes,
852 MessageEventHandler * const eventProcessor);
853
854
861 Path& operator=(const Path &rhs) = delete;
867 Path(const Path &source) = delete;
868
869 protected:
877 virtual void Disconnected();
878
879
880
881 public:
887 Path& operator=(Path &&rhs) = default;
892 Path(Path &&source) = default;
893 /* Normal constructor
894 *
895 * Allows the the task name, host and file to be set
896 *
897 * @note DRAMA does not directly deal with long program names (value of
898 * the file argument). The limit is about 63 characters. The work
899 * around for this is to use environment variables known to IMP_Master
900 * on the machine doing the loading (node). The normal approach is to
901 * use the ENVVAR:program approach to specifying the node name. E.g.
902 * rather then specifying a filename like this:
903 * <pre>
904 * /directory1/diretory2/directory3/directory4/program
905 * </pre>
906 *
907 * There would be an environment variable know to the IMP_Master
908 * program defined like this:
909 * <pre>
910 * export ENVVAR=/directory1/diretory2/directory3/directory4/
911 * </pre>
912 * And then the ENVVAR:program name will work. Remember that
913 * IMP_Master is normally started using dits_netstart.
915 *
916 * @param theTask The DRAMA Task we are part of. This is passed
917 * by pointer, but Path is not taking ownership of
918 * the subject object, which must continue to exist
919 * until the Path object is destroyed.
920 * @param name The name the task will be known as (unless loaded,
921 * when the name the task registers as will be used)
922 * @param host The node name on which the task is running or
923 * is to be loaded. Only used if not already running
924 * locally or known locally.
925 * @param file The file of the task, as required by
926 * DCF(DitsLoad). Normally a file name, but may
927 * be different depending on the location, e.g.
928 * on a VxWorks machine.
929 */
930 Path(std::weak_ptr<Task> theTask,
931 const std::string &name,
932 const std::string &host = "",
933 const std::string &file = "");
934
935
936 /* Normal constructor
937 *
938 * Allows the the task name, host and file to be set
939 *
940 * @note DRAMA does not directly deal with long program names (value of
941 * the file argument). The limit is about 63 characters. The work
942 * around for this is to use environment variables known to IMP_Master
943 * on the machine doing the loading (node). The normal approach is to
944 * use the ENVVAR:program approach to specifying the node name. E.g.
945 * rather then specifying a filename like this:
946 * <pre>
947 * /directory1/diretory2/directory3/directory4/program
948 * </pre>
949 *
950 * There would be an environment variable know to the IMP_Master
951 * program defined like this:
952 * <pre>
953 * export ENVVAR=/directory1/diretory2/directory3/directory4/
954 * </pre>
955 * And then the ENVVAR:program name will work. Remember that
956 * IMP_Master is normally started using dits_netstart.
957 *
958 *
959 * @param theTask The DRAMA Task we are part of. This is passed
960 * by pointer, but Path is not taking ownership of
961 * the subject object, which must continue to exist
962 * until the Path object is destroyed.
963 * @param name The name the task will be known as (unless loaded,
964 * when the name the task registers as will be used)
965 * @param host The node name on which the task is running or
966 * is to be loaded. Only used if not already running
967 * locally or known locally.
968 * @param file The file of the task, as required by
969 * DCF(DitsLoad). Normally a file name, but may
970 * be different depending on the location, e.g.
971 * on a VxWorks machine.
972 */
973 Path(std::shared_ptr<Task> theTask,
974 const std::string &name,
975 const std::string &host = "",
976 const std::string &file = "");
977
978
989 explicit Path(std::weak_ptr<Task> theTask);
990
991
1006 Path(std::weak_ptr<Task> theTask, DitsPathType path);
1007
1013 Path() { }
1014
1017 virtual ~Path();
1026 void Report(thread::TMessHandler *action) const;
1027 /*
1028 * Inquiries
1029 */
1034 bool GetPathLoaded() const { return (_loaded); };
1043 const std::string GetTaskName() const;
1053 const std::string &GetHost() const { return (_taskLocation); }
1058 const std::string &GetArgument() const { return (_argument); };
1059
1060 /*
1061 * Routines to set various load and get path options.
1062 */
1076 virtual void SetName(const std::string &TaskName);
1084 virtual void SetHost(const std::string & Host) {
1085 _taskLocation = Host;
1086 }
1111 virtual void SetFile(const std::string &File) {
1112 _taskFile = File;
1113 }
1122 virtual void SetBuffers(const Buffers & buffs) {
1123 this->_buffers = buffs;
1124 }
1130 virtual void SetFlowControl() {
1131 _pathFlags |= DITS_M_FLOW_CONTROL;
1132 }
1144 virtual void SetProcess(const std::string &ProcessName);
1145
1154 virtual void SetStackSize(unsigned bytes);
1155
1166 virtual void SetArgument(const std::string &LoadArg,
1167 bool const Append=false);
1179 virtual void SetPriority(const int Priority,
1180 const bool Absolute = false);
1198 virtual void SetNames(const bool Flag = true) {
1199 if (Flag)
1200 _loadFlags |= DITS_M_NAMES;
1201 else
1202 _loadFlags &= ~DITS_M_NAMES;
1203 }
1216 virtual void SetSymbols(const bool Flag = true) {
1217 Task::guardType DramaLock(std::shared_ptr<Task>(_theTask)->Lock()); // Grab DRAMA Lock if we don't have it.
1218 if (Flag)
1219 _loadFlags |= DITS_M_SYMBOL;
1220 else
1221 _loadFlags &= ~DITS_M_SYMBOL;
1222 };
1239 virtual void SetProg(const bool Flag = true) {
1240 Task::guardType DramaLock(std::shared_ptr<Task>(_theTask)->Lock()); // Grab DRAMA Lock if we don't have it.
1241 if (Flag)
1242 _loadFlags |= DITS_M_PROG;
1243 else
1244 _loadFlags &= ~DITS_M_PROG;
1245 };
1253 virtual void LogLoad(const bool Flag = true) {
1254 _logLoad = Flag;
1255 }
1256
1262 virtual void ClearState() {
1263 _state = PathState::INITIAL;
1264 };
1271 virtual bool Active() const {
1272 return ((_state == PathState::ACTIVE)||
1273 (_state == PathState::SELFINIT));
1274 }
1279 virtual bool IsDead() const {
1280 return (_state == PathState::DIED);
1281 }
1286 virtual bool Initial() const {
1287 return ((_state == PathState::INITIAL)||
1288 (_state == PathState::DIED));
1297 virtual bool Busy() const {
1298 return ((_state == PathState::PATHWAIT) ||
1299 (_state == PathState::LOADING) ||
1300 (_state == PathState::NOTIFY));
1301 }
1302
1307 virtual std::shared_ptr<Task> GetTask() const {
1308 return std::shared_ptr<Task>(_theTask);
1309 }
1310
1332 void GetPath(thread::TMessHandler *action,
1333 thread::TransEvtProcessor * const eventProcessor = &_getPathEventProcessor );
1368 bool GetPathWaitUntil(std::chrono::steady_clock::time_point until,
1370 thread::TransEvtProcessor * const eventProcessor = &_getPathEventProcessor );
1371
1390 const std::string &name,
1392 sds::IdPtr * const argOut = nullptr,
1393 MessageEventHandler * const eventProcessor = &_simpleEventProcessor) {
1394
1395#if 0
1396 fprintf(stderr,"!!!OBey - sending action %s\n", name.c_str());
1397#endif
1398
1399 Send(action, DITS_MSG_OBEY, name, 0 /* Flags */, argIn, eventProcessor);
1400#if 0
1401 fprintf(stderr,"!!!Obey sent, waiting for reply\n");
1402#endif
1403 TransEvtInfo eventInfo;
1404 action->WaitForTransaction(_theTask,
1405 &eventInfo, eventProcessor, argOut);
1406#if 0
1407 fprintf(stderr,"!!!Obey sent, wait complete\n");
1408#endif
1409/* This should not be needed, event processor will throw if needed */
1410/* if (eventInfo.entryStatus != STATUS__OK)
1411 {
1412 DramaTHROW_F(
1413 eventInfo.entryStatus,
1414 "Obey of message {0} to task {1} completed with error",
1415 name, _taskName);
1417 else */ if (eventInfo.complete == 0)
1418 {
1420 eventInfo.entryStatus,
1421 "Obey of message {0} to task {1}, returned but not complete",
1422 name, _taskName);
1423 }
1424
1425 }
1426
1436 static std::chrono::steady_clock::time_point DeltaToTimePoint(int secs) {
1437 return std::chrono::steady_clock::now() + std::chrono::seconds(secs);
1438 }
1439
1470 bool ObeyWaitUntil(std::chrono::steady_clock::time_point until,
1471 thread::TMessHandler *action,
1472 const std::string &name,
1473 const sds::Id &argIn = sds::Id::CreateNullItem(),
1474 sds::IdPtr * const argOut = nullptr,
1475 MessageEventHandler * const eventProcessor = &_simpleEventProcessor) {
1476
1477 Send(action, DITS_MSG_OBEY, name, 0 /* Flags */, argIn, eventProcessor);
1478
1479 TransEvtInfo eventInfo;
1480 bool ok = action->WaitForTransactionUntil(
1481 _theTask,
1482 &eventInfo, eventProcessor,
1483 until, argOut);
1484
1485 if (!ok) return false;
1486
1487/* This should not be needed, event processor will throw if needed */
1488/* if (eventInfo.entryStatus != STATUS__OK)
1489 {
1490 DramaTHROW_F(
1491 eventInfo.entryStatus,
1492 "Obey of action {0} to task {1} completed with error",
1493 name, _taskName);
1494 }
1495 else */ if (eventInfo.complete == 0)
1496 {
1498 eventInfo.entryStatus,
1499 "Obey of action {0} to task {1}, returned but not complete",
1500 name, _taskName);
1501 }
1502 return true;
1503
1504 }
1505
1537 void ObeyBulk(thread::TMessHandler *action,
1538 const std::string &name,
1539 BulkData *argIn,
1540 bool isSds,
1541 unsigned notifyBytes=1024*1024,
1542 sds::IdPtr * const argOut = nullptr,
1543 MessageEventHandler * const eventProcessor = &_simpleEventProcessor) {
1544
1545#if 0
1546 fprintf(stderr,"!!!OBeyBulk - sending action %s\n", name.c_str());
1547#endif
1548
1549 SendBulk(action, DITS_MSG_OBEY, name, 0 /* Flags */, argIn, isSds,
1551#if 0
1552 fprintf(stderr,"!!!ObeyBulk sent, waiting for reply\n");
1553#endif
1554 TransEvtInfo eventInfo;
1555 action->WaitForTransaction(_theTask,
1556 &eventInfo, eventProcessor, argOut);
1557#if 0
1558 fprintf(stderr,"!!!ObeyBulk sent, wait complete\n");
1559#endif
1560/* This should not be needed, event processor will throw if needed */
1561/* if (eventInfo.entryStatus != STATUS__OK)
1562 {
1563 DramaTHROW_F(
1564 eventInfo.entryStatus,
1565 "ObeyBulk of message {0} to task {1} completed with error",
1566 name, _taskName);
1567 }
1568 else */ if (eventInfo.complete == 0)
1569 {
1571 eventInfo.entryStatus,
1572 "ObeyBulk of message {0} to task {1}, returned but not complete",
1573 name, _taskName);
1574 }
1575
1576 }
1577
1578
1604 void ObeyBulk(thread::TMessHandler *action,
1605 const std::string &name,
1606 BulkDataSds *argIn,
1607 unsigned notifyBytes=1024*1024,
1608 sds::IdPtr * const argOut = nullptr,
1609 MessageEventHandler * const eventProcessor = &_simpleEventProcessor) {
1610
1611
1613 }
1614
1615
1616
1663 bool ObeyBulkWaitUntil(std::chrono::steady_clock::time_point until,
1664 thread::TMessHandler *action,
1665 const std::string &name,
1666 BulkData *argIn,
1667 bool isSds,
1668 unsigned notifyBytes=1024*1024,
1669 sds::IdPtr * const argOut = nullptr,
1670 MessageEventHandler * const eventProcessor = &_simpleEventProcessor) {
1671
1672 SendBulk(action, DITS_MSG_OBEY, name, 0 /* Flags */, argIn,
1674
1675 TransEvtInfo eventInfo;
1676 bool ok = action->WaitForTransactionUntil(
1677 _theTask,
1678 &eventInfo, eventProcessor,
1679 until, argOut);
1680
1681 if (!ok) return false;
1682
1683/* This should not be needed, event processor will throw if needed */
1684/* if (eventInfo.entryStatus != STATUS__OK)
1685 {
1686 DramaTHROW_F(
1687 eventInfo.entryStatus,
1688 "Obey of action {0} to task {1} completed with error",
1689 name, _taskName);
1691 else*/ if (eventInfo.complete == 0)
1692 {
1694 eventInfo.entryStatus,
1695 "Obey of action {0} to task {1}, returned but not complete",
1696 name, _taskName);
1697 }
1698 return true;
1699
1700 }
1701
1702
1743 bool ObeyBulkWaitUntil(std::chrono::steady_clock::time_point until,
1744 thread::TMessHandler *action,
1745 const std::string &name,
1746 BulkDataSds *argIn,
1747 unsigned notifyBytes=1024*1024,
1748 sds::IdPtr * const argOut = nullptr,
1749 MessageEventHandler * const eventProcessor = &_simpleEventProcessor) {
1750
1751
1752 return ObeyBulkWaitUntil(until, action, name, argIn, true,
1754
1755 }
1774 void Kick(thread::TMessHandler *action,
1775 const std::string &name,
1776 const sds::Id &argIn = sds::Id::CreateNullItem(),
1777 sds::IdPtr * const argOut = nullptr,
1778 MessageEventHandler * const eventProcessor = &_simpleEventProcessor) {
1779
1780 Send(action, DITS_MSG_KICK, name, 0 /* Flags */, argIn, eventProcessor);
1781
1782 TransEvtInfo eventInfo;
1783 action->WaitForTransaction(_theTask,
1784 &eventInfo, eventProcessor,
1785 argOut);
1786/* This should not be needed, event processor will throw if needed */
1787/* if (eventInfo.entryStatus != STATUS__OK)
1788 {
1789 DramaTHROW_F(
1790 eventInfo.entryStatus,
1791 "Kick of action {0} in task {1} completed with error",
1792 name, _taskName);
1793 }
1794 else */ if (eventInfo.complete == 0)
1795 {
1797 eventInfo.entryStatus,
1798 "Kick of action {0} in task {1}, returned but not complete",
1799 name, _taskName);
1800 }
1802 }
1803
1834 bool KickWaitUntil(std::chrono::steady_clock::time_point until,
1836 const std::string &name,
1838 sds::IdPtr * const argOut = nullptr,
1839 MessageEventHandler * const eventProcessor = &_simpleEventProcessor) {
1840
1841 Send(action, DITS_MSG_KICK, name, 0 /* Flags */, argIn, eventProcessor);
1842
1843 TransEvtInfo eventInfo;
1844 bool ok = action->WaitForTransactionUntil(
1845 _theTask,
1846 &eventInfo, eventProcessor,
1847 until, argOut);
1848
1849 if (!ok) return false;
1850
1851/* This should not be needed, event processor will throw if needed */
1852/* if (eventInfo.entryStatus != STATUS__OK)
1853 {
1854 DramaTHROW_F(
1855 eventInfo.entryStatus,
1856 "Kick of action {0} in task {1} completed with error",
1857 name, _taskName);
1858 }
1859 else */ if (eventInfo.complete == 0)
1860 {
1862 eventInfo.entryStatus,
1863 "Kick of action {0} in task {1}, returned but not complete",
1864 name, _taskName);
1865 }
1866 return true;
1867
1868 }
1869
1902 void KickBulk(thread::TMessHandler *action,
1903 const std::string &name,
1904 BulkData *argIn,
1905 bool isSds,
1906 unsigned notifyBytes=1024*1024,
1907 sds::IdPtr * const argOut = nullptr,
1908 MessageEventHandler * const eventProcessor = &_simpleEventProcessor) {
1909
1910 SendBulk(action, DITS_MSG_KICK, name, 0 /* Flags */, argIn, isSds,
1912
1913 TransEvtInfo eventInfo;
1914 action->WaitForTransaction(_theTask,
1915 &eventInfo, eventProcessor,
1916 argOut);
1917/* This should not be needed, event processor will throw if needed */
1918/* if (eventInfo.entryStatus != STATUS__OK)
1919 {
1920 DramaTHROW_F(
1921 eventInfo.entryStatus,
1922 "Kick of action {0} in task {1} completed with error",
1923 name, _taskName);
1924 }
1925 else */ if (eventInfo.complete == 0)
1926 {
1928 eventInfo.entryStatus,
1929 "Kick of action {0} in task {1}, returned but not complete",
1930 name, _taskName);
1931 }
1932
1933 }
1934
1961 void KickBulk(thread::TMessHandler *action,
1962 const std::string &name,
1963 BulkDataSds *argIn,
1964 unsigned notifyBytes=1024*1024,
1965 sds::IdPtr * const argOut = nullptr,
1966 MessageEventHandler * const eventProcessor = &_simpleEventProcessor) {
1967
1969 }
1970
1971
1972
2017 bool KickBulkWaitUntil(std::chrono::steady_clock::time_point until,
2018 thread::TMessHandler *action,
2019 const std::string &name,
2020 BulkData *argIn,
2021 bool isSds,
2022 unsigned notifyBytes=1024*1024,
2023 sds::IdPtr * const argOut = nullptr,
2024 MessageEventHandler * const eventProcessor = &_simpleEventProcessor) {
2025
2026 SendBulk(action, DITS_MSG_KICK, name, 0 /* Flags */, argIn, isSds,
2028
2029 TransEvtInfo eventInfo;
2030 bool ok = action->WaitForTransactionUntil(
2031 _theTask,
2032 &eventInfo, eventProcessor,
2033 until, argOut);
2034
2035 if (!ok) return false;
2036
2037/* This should not be needed, event processor will throw if needed */
2038/* if (eventInfo.entryStatus != STATUS__OK)
2039 {
2040 DramaTHROW_F(
2041 eventInfo.entryStatus,
2042 "Kick of action {0} in task {1} completed with error",
2043 name, _taskName);
2045 else */ if (eventInfo.complete == 0)
2046 {
2048 eventInfo.entryStatus,
2049 "Kick of action {0} in task {1}, returned but not complete",
2050 name, _taskName);
2051 }
2052 return true;
2053
2054 }
2055
2056
2095 bool KickBulkWaitUntil(std::chrono::steady_clock::time_point until,
2096 thread::TMessHandler *action,
2097 const std::string &name,
2098 BulkDataSds *argIn,
2099 unsigned notifyBytes=1024*1024,
2100 sds::IdPtr * const argOut = nullptr,
2101 MessageEventHandler * const eventProcessor = &_simpleEventProcessor) {
2102 return KickBulkWaitUntil(until, action, name, argIn,
2104 }
2105
2106
2119 void SetParam(thread::TMessHandler *action,
2120 const std::string &name,
2121 const sds::Id &argIn,
2122 MessageEventHandler * const eventProcessor = &_simpleEventProcessor) {
2123
2124 Send(action, DITS_MSG_SETPARAM, name, 0 /* Flags */, argIn, eventProcessor);
2125
2126 TransEvtInfo eventInfo;
2127 action->WaitForTransaction(_theTask,
2128 &eventInfo, eventProcessor);
2129/* This should not be needed, event processor will throw if needed */
2130/* if (eventInfo.entryStatus != STATUS__OK)
2131 {
2132 DramaTHROW_F(
2133 eventInfo.entryStatus,
2134 "Set of parameter {0} in task {1} completed with error",
2135 name, _taskName);
2136 }
2137 else */ if (eventInfo.complete == 0)
2138 {
2140 eventInfo.entryStatus,
2141 "Set of parameter {0} in task {1}, returned but not complete",
2142 name, _taskName);
2143 }
2144
2145 }
2171 bool SetParamWaitUntil(std::chrono::steady_clock::time_point until,
2173 const std::string &name,
2174 const sds::Id &argIn,
2175 MessageEventHandler * const eventProcessor = &_simpleEventProcessor) {
2176
2177 Send(action, DITS_MSG_SETPARAM, name, 0 /* Flags */, argIn, eventProcessor);
2178
2179 TransEvtInfo eventInfo;
2180 bool ok = action->WaitForTransactionUntil(
2181 _theTask,
2182 &eventInfo, eventProcessor,
2183 until);
2184
2185 if (!ok) return false;
2186
2187/* This should not be needed, event processor will throw if needed */
2188/* if (eventInfo.entryStatus != STATUS__OK)
2189 {
2190 DramaTHROW_F(
2191 eventInfo.entryStatus,
2192 "Set of parameter {0} in task {1} completed with error",
2193 name, _taskName);
2194 }
2195 else */ if (eventInfo.complete == 0)
2196 {
2198 eventInfo.entryStatus,
2199 "Set of parameter {0} in task {1}, returned but did not complete",
2200 name, _taskName);
2201 }
2202 return true;
2203
2204 }
2205
2206
2219 void GetParam(thread::TMessHandler *action,
2220 const std::string &name,
2221 sds::IdPtr * const argOut,
2222 MessageEventHandler * const eventProcessor = &_simpleEventProcessor) {
2223 Send(action, DITS_MSG_GETPARAM, name, 0 /* Flags */,
2224 sds::Id::CreateNullItem() /* arg */,
2226
2227 TransEvtInfo eventInfo;
2228 action->WaitForTransaction(_theTask,
2229 &eventInfo, eventProcessor,
2230 argOut);
2231/* This should not be needed, event processor will throw if needed */
2232/* if (eventInfo.entryStatus != STATUS__OK)
2233 {
2234 DramaTHROW_F(
2235 eventInfo.entryStatus,
2236 "Get of parameter {0} from task {1} completed with error",
2237 name, _taskName);
2238 }
2239 else */ if (eventInfo.complete == 0)
2240 {
2242 eventInfo.entryStatus,
2243 "Get of parameter {0} from task {1}, returned but not complete",
2244 name, _taskName);
2245 }
2247 }
2263 const std::initializer_list<std::string> names,
2264 sds::IdPtr * const argOut,
2265 MessageEventHandler * const eventProcessor = &_simpleEventProcessor) {
2267
2268 Send(action, DITS_MSG_MGETPARAM, "", 0 /* Flags */, argIn,
2270
2271 TransEvtInfo eventInfo;
2272 action->WaitForTransaction(_theTask,
2273 &eventInfo, eventProcessor, argOut);
2274/* This should not be needed, event processor will throw if needed */
2275/* if (eventInfo.entryStatus != STATUS__OK)
2276 {
2277 DramaTHROW_F(
2278 eventInfo.entryStatus,
2279 "Get of parameters from task {0} completed with error",
2280 _taskName);
2281 }
2282 else */ if (eventInfo.complete == 0)
2283 {
2285 eventInfo.entryStatus,
2286 "Get of parameters from task {0}, returned but not complete",
2287 _taskName);
2288 }
2290 }
2291
2292
2293
2294
2320 bool GetParamWaitUntil(std::chrono::steady_clock::time_point until,
2322 const std::string &name,
2323 sds::IdPtr * const argOut,
2324 MessageEventHandler * const eventProcessor = &_simpleEventProcessor) {
2325 Send(action, DITS_MSG_GETPARAM, name, 0 /* Flags */,
2326 sds::Id::CreateNullItem() /* arg */,
2328
2329 TransEvtInfo eventInfo;
2330 bool ok = action->WaitForTransactionUntil(
2331 _theTask,
2332 &eventInfo, eventProcessor,
2333 until, argOut);
2334 if (!ok) return false;
2335
2336/* This should not be needed, event processor will throw if needed */
2337/* if (eventInfo.entryStatus != STATUS__OK)
2338 {
2339 DramaTHROW_F(
2340 eventInfo.entryStatus,
2341 "Get of parameter {0} from task {1} completed with error",
2342 name, _taskName);
2343 }
2344 else */ if (eventInfo.complete == 0)
2345 {
2347 eventInfo.entryStatus,
2348 "Get of parameter {0} from task {1}, returned but not complete",
2349 name, _taskName);
2350 }
2351 return true;
2352
2353 }
2380 bool GetParamWaitUntil(std::chrono::steady_clock::time_point until,
2381 thread::TMessHandler *action,
2382 const std::initializer_list<std::string> names,
2383 sds::IdPtr * const argOut,
2384 MessageEventHandler * const eventProcessor = &_simpleEventProcessor) {
2386
2387 Send(action, DITS_MSG_MGETPARAM, "", 0 /* Flags */, argIn,
2389
2390 TransEvtInfo eventInfo;
2391 bool ok = action->WaitForTransactionUntil(
2392 _theTask,
2393 &eventInfo, eventProcessor,
2394 until, argOut);
2395 if (!ok) return false;
2396/* This should not be needed, event processor will throw if needed */
2397/* if (eventInfo.entryStatus != STATUS__OK)
2398 {
2399 DramaTHROW_F(
2400 eventInfo.entryStatus,
2401 "Get of parameters from task {0} completed with error",
2402 _taskName);
2403 }
2404 else */
2405 if (eventInfo.complete == 0)
2406 {
2408 eventInfo.entryStatus,
2409 "Get of parameters from task {0}, returned but not complete",
2410 _taskName);
2411 }
2412 return true;
2413
2414 }
2415
2416
2435 void Control(thread::TMessHandler *action,
2436 const std::string &name,
2437 const sds::Id &argIn = sds::Id::CreateNullItem(),
2438 sds::IdPtr * const argOut = nullptr,
2439 MessageEventHandler * const eventProcessor = &_simpleEventProcessor) {
2440
2441 Send(action, DITS_MSG_CONTROL, name, 0 /* Flags */, argIn,
2443
2444 TransEvtInfo eventInfo;
2445 action->WaitForTransaction(_theTask,
2446 &eventInfo, eventProcessor,
2447 argOut);
2448/* This should not be needed, event processor will throw if needed */
2449/* if (eventInfo.entryStatus != STATUS__OK)
2450 {
2451 DramaTHROW_F(
2452 eventInfo.entryStatus,
2453 "Control message {0} to task {1} completed with error",
2454 name, _taskName);
2455 }
2456 else */ if (eventInfo.complete == 0)
2457 {
2459 eventInfo.entryStatus,
2460 "Control message {0} to task {1}, returned but did not complete",
2461 name, _taskName);
2463
2464 }
2465
2496 bool ControlWaitUntil(std::chrono::steady_clock::time_point until,
2497 thread::TMessHandler *action,
2498 const std::string &name,
2499 const sds::Id &argIn = sds::Id::CreateNullItem(),
2500 sds::IdPtr * const argOut = nullptr,
2501 MessageEventHandler * const eventProcessor = &_simpleEventProcessor) {
2502
2503 Send(action, DITS_MSG_CONTROL, name, 0 /* Flags */, argIn,
2505
2506 TransEvtInfo eventInfo;
2507 bool ok = action->WaitForTransactionUntil(
2508 _theTask,
2509 &eventInfo, eventProcessor,
2510 until, argOut);
2511
2512 if (!ok) return false;
2513
2514/* This should not be needed, event processor will throw if needed */
2515/* if (eventInfo.entryStatus != STATUS__OK)
2516 {
2517 DramaTHROW_F(
2518 eventInfo.entryStatus,
2519 "Control message {0} to task {1} completed with error",
2520 name, _taskName);
2521 }
2522 else */ if (eventInfo.complete == 0)
2525 eventInfo.entryStatus,
2526 "Control message {0} to task {1}, returned but not complete",
2527 name, _taskName);
2528 }
2529 return true;
2530
2531 }
2532
2533
2544 virtual void GetPathImmed();
2545
2546
2547
2550 virtual void Died() {
2551 _path = 0;
2552 _state = PathState::DIED;
2553 }
2564 virtual void LosePath();
2573 virtual void Delete(int force);
2574
2575
2576
2595 const sds::Id &argIn,
2597
2598 //fprintf(stderr,"MonitorStart - about to send monitor\n");
2601
2602 TransEvtInfo eventInfo;
2603 //fprintf(stderr,"MonitorStart - about to wait\n");
2604 action->WaitForTransaction(_theTask,
2605 &eventInfo, eventProcessor, nullptr);
2606 //fprintf(stderr,"MonitorStart - wait complete.\n");
2607/* This should not be needed, event processor will throw if needed */
2608/* if (eventInfo.entryStatus != STATUS__OK)
2609 {
2610 DramaTHROW_F(
2611 eventInfo.entryStatus,
2612 "Monitor Start message to task {0} completed with error",
2613 _taskName);
2614 }
2615 else */ if (eventInfo.complete == 0)
2616 {
2618 eventInfo.entryStatus,
2619 "Monitor START to task {0}, returned but did not complete",
2620 _taskName);
2622
2623 }
2643 void MonitorForward(thread::TMessHandler *action,
2644 const sds::Id &argIn,
2645 MessageEventHandler * const eventProcessor = &_simpleMonEventProcessor) {
2646
2647 Send(action, DITS_MSG_MONITOR, "FORWARD", DITS_M_SENDCUR, argIn,
2649
2650 TransEvtInfo eventInfo;
2651 action->WaitForTransaction(_theTask,
2652 &eventInfo, eventProcessor, nullptr);
2653/* This should not be needed, event processor will throw if needed */
2654/* if (eventInfo.entryStatus != STATUS__OK)
2655 {
2656 DramaTHROW_F(
2657 eventInfo.entryStatus,
2658 "Monitor FORWARD message to task {0} completed with error",
2659 _taskName);
2660 }
2661 else */ if (eventInfo.complete == 0)
2662 {
2664 eventInfo.entryStatus,
2665 "Monitor FORWARD to task {0}, returned but not complete",
2666 _taskName);
2667 }
2668
2669 }
2671
2672
2689 const std::string &task,
2690 const std::string action,
2691 std::initializer_list<std::string> pars,
2692 MessageEventHandler * const eventProcessor = &_simpleMonEventProcessor) {
2693
2695 args.Put("TASK", task);
2696 args.Put("ACTION", action);
2697 args.AddToArgCmdStruct(pars, 3);
2698
2700
2701 }
2725 template <typename ContainerType>
2727 const std::string &task,
2728 const std::string action,
2729 const ContainerType &pars,
2730 MessageEventHandler * const eventProcessor = &_simpleMonEventProcessor) {
2731
2732 static_assert(
2733 std::is_convertible<typename ContainerType::value_type,std::string>::value,
2734 "The container value type must be convertible to a std::string");
2735
2737 args.Put("TASK", task);
2738 args.Put("ACTION", action);
2739 args.AddToArgCmdStruct(pars, 3);
2740
2742
2743 }
2744
2745
2756 void MonitorCancel(thread::TMessHandler *action,
2757 int monId,
2758 MessageEventHandler * const eventProcessor = &_simpleEventProcessor) {
2759
2760 sds::Id argIn = sds::Id::CreateArgCmdStruct(std::vector<INT32>{monId});
2761 Send(action, DITS_MSG_MONITOR, "CANCEL", DITS_M_SENDCUR, argIn,
2763
2764 TransEvtInfo eventInfo;
2765 action->WaitForTransaction(_theTask,
2766 &eventInfo, eventProcessor, nullptr);
2767/* This should not be needed, event processor will throw if needed */
2768/* if (eventInfo.entryStatus != STATUS__OK)
2769 {
2770 DramaTHROW_F(
2771 eventInfo.entryStatus,
2772 "Monitor CANCEL message to task {0} completed with error",
2773 _taskName);
2774 }
2775 else */ if (eventInfo.complete == 0)
2776 {
2778 eventInfo.entryStatus,
2779 "Monitor CANCEL to task {0}, returned but not complete",
2780 _taskName);
2781 }
2782
2784
2785
2798 virtual DitsPathType GetDitsPath(bool nothrow=false);
2799
2809 static DVOID HandleDisconnected(const char *task,
2810 DitsPathType path,
2812
2821
2830
2831
2832 }; /* class Path */
2833
2834
2835} // namespace drama
2837#endif
2838
long int MaxMessages() const
Return the Max Messages specification.
Definition path.hh:165
Buffers(const DitsPathInfoType &info)
Construct a drama::Buffers object from a DitsPathInfoType variable.
Definition path.hh:150
long int MaxReplies() const
Return the Max Replies specification.
Definition path.hh:175
long int MessageBytes() const
Return the message bytes specification.
Definition path.hh:160
long int ReplyBytes() const
Return the reply bytes specification.
Definition path.hh:170
Buffers(long int MessageBytes=800, long int MaxMessages=2, long int ReplyBytes=800, long int MaxReplies=10)
Construct a drama::Buffers object from individual specifications.
Definition path.hh:135
A Class which supports setting up DRAMA message buffer structures.
Definition path.hh:120
Defines and optionally creates a shared memory section containing an SDS structure.
Definition bulkdata.hh:434
Defines and optionally creates a shared memory section.
Definition bulkdata.hh:121
virtual bool Process(thread::ProcessInfo messInfo, const TransEvtInfo &eventInfo, const sds::IdPtr &arg) override
This method is invoked for each message received in response to a GetPath operation.
virtual void NewTransaction(DitsMsgType msgType, DitsTransIdType tid) override
This method is invoked each time a messages is initiated.
Default event handler type for GetPath() calls.
Definition path.hh:476
void SetStatus(EventStatus newVal)
If a sub-class overrides one of the methods of MessageEventHandler that this class overrides,...
Definition path.hh:588
void NewTransaction(DitsMsgType msgType, DitsTransIdType tid) override
Invoked when a new transaction is started.
virtual void TaskDied(drama::thread::ProcessInfo messInfo, StatusType status) override
Invoked if the subsidiary task died whilst we were waiting for a reply from it.
std::string GetStr() const
Return a string version of the current event status values.
Definition path.hh:557
bool operator()() const
Indicate if the message is outstanding (running)
Definition path.hh:564
EventStatus
Detailed status of the message is returned using this enum.
Definition path.hh:534
@ Completed
The message has completed successfully.
@ Running
The message has been sent and has not completed.
@ Failed
The message has completed with a failure.
@ NotStarted
The message has not been sent as yet.
IsRunningType()
Constructor.
Definition path.hh:577
EventStatus Get() const
Return the status of the message.
Definition path.hh:544
void MessageRejected(drama::thread::ProcessInfo messInfo, StatusType status) override
Invoked for when a message is rejected.
std::string GetStr(EventStatus val) const
Return a string version of a event status value.
virtual void MessageComplete(drama::thread::ProcessInfo messInfo, StatusType status, const drama::sds::IdPtr &arg) override
Invoked if a message complete message is received.
A message event handling object that maintains a variable indicating if the message is outstanding.
Definition path.hh:529
virtual void BulkTransferred(thread::ProcessInfo messInfo, DitsBulkInfoType bulkInfo)
Invoked if a bulk data transferred message is received.
virtual void UserMessage(thread::ProcessInfo messInfo, const std::string &task, const std::string &message)
Invoked if a message for the user is received.
virtual void SignalReceived(thread::ProcessInfo messInfo, const sds::IdPtr &arg)
Invoked if a signal for the action is received.
virtual void NewTransaction(DitsMsgType msgType, DitsTransIdType tid) override
This method is invoked each time a message is initiated.
virtual void MessageRejected(thread::ProcessInfo messInfo, StatusType status)
Invoked if the message sent was rejected by the target task.
virtual void BulkDone(thread::ProcessInfo messInfo)
Invoked if a bulk data done message is received.
virtual void ThreadWaitAbort(thread::ProcessInfo messInfo, StatusType status)
Invoked if the thread wait is aborted.
virtual bool KickReceived(thread::ProcessInfo messInfo, const sds::IdPtr &arg)
Invoked if an action waiting on a message receives a kick message during the wait.
virtual bool Process(thread::ProcessInfo messInfo, const TransEvtInfo &eventInfo, const sds::IdPtr &arg) override final
Method invoked to process messages.
virtual void TaskDied(thread::ProcessInfo messInfo, StatusType status)
Invoked if the subsidiary task died whilst we were waiting for a reply from it.
virtual void MessageComplete(thread::ProcessInfo messInfo, StatusType status, const sds::IdPtr &arg)
Invoked if a message complete message is received.
virtual void TriggerReceived(thread::ProcessInfo messInfo, StatusType status, const sds::IdPtr &arg)
Invoked if a trigger message is received.
virtual void ErrorReport(thread::ProcessInfo messInfo, const std::string &task, const ErsMessageVector &messages)
Invoked if an error report for the user is received.
Message event handling objects.
Definition path.hh:194
virtual void TriggerReceived(thread::ProcessInfo messInfo, StatusType status, const sds::IdPtr &arg) override
Invoked if a trigger message is received.
Forward monitor message event handling objects.
Definition path.hh:452
void Kick(thread::TMessHandler *action, const std::string &name, const sds::Id &argIn=sds::Id::CreateNullItem(), sds::IdPtr *const argOut=nullptr, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
Sends a kick message to a task and blocks the current thread until the reply is received.
Definition path.hh:1801
virtual void SetPriority(const int Priority, const bool Absolute=false)
Set the load time priority for a task when loaded.
virtual void Disconnected()
Invoked when the task we are talking to disappears.
virtual ~Path()
Destructor.
void KickBulk(thread::TMessHandler *action, const std::string &name, BulkData *argIn, bool isSds, unsigned notifyBytes=1024 *1024, sds::IdPtr *const argOut=nullptr, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
Sends a kick message, with bulk data argument, to a task and blocks the current thread until the repl...
Definition path.hh:1929
void MonitorForward(thread::TMessHandler *taction, const std::string &task, const std::string action, const ContainerType &pars, MessageEventHandler *const eventProcessor=&_simpleMonEventProcessor)
Send a Monitor Forward message to a task and block until it is complete.
Definition path.hh:2753
Path(Path &&source)=default
Move copy constructor.
void Report(thread::TMessHandler *action) const
Dump details using <a href="../routines/MsgOut.html">MsgOut()</a>.
void MonitorStart(thread::TMessHandler *action, const sds::Id &argIn, MessageEventHandler *const eventProcessor)
Send a Monitor Start message to a task and block until is it is complete.
Definition path.hh:2621
virtual void SetFlowControl()
Set the FLOW control flag.
Definition path.hh:1157
virtual void LosePath()
Lose the path and then set as if the task has died.
void ObeyBulk(thread::TMessHandler *action, const std::string &name, BulkData *argIn, bool isSds, unsigned notifyBytes=1024 *1024, sds::IdPtr *const argOut=nullptr, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
Sends an obey message to a task, with bulk data argument, and blocks the current thread until the act...
Definition path.hh:1564
bool GetPathWaitUntil(std::chrono::steady_clock::time_point until, thread::TMessHandler *action, thread::TransEvtProcessor *const eventProcessor=&_getPathEventProcessor)
Get a path to a the task.
bool ObeyBulkWaitUntil(std::chrono::steady_clock::time_point until, thread::TMessHandler *action, const std::string &name, BulkData *argIn, bool isSds, unsigned notifyBytes=1024 *1024, sds::IdPtr *const argOut=nullptr, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
Sends an obey message to a task, with a bulk data argument, and blocks the current thread until the a...
Definition path.hh:1690
void GetParam(thread::TMessHandler *action, const std::initializer_list< std::string > names, sds::IdPtr *const argOut, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
Sends a get parameter message to a task and blocks the current thread until it completes.
Definition path.hh:2289
void MonitorForward(thread::TMessHandler *taction, const std::string &task, const std::string action, std::initializer_list< std::string > pars, MessageEventHandler *const eventProcessor=&_simpleMonEventProcessor)
Send a Monitor Forward message to a task and block until it is complete.
Definition path.hh:2715
const std::string & GetArgument() const
Fetch the load argument.
Definition path.hh:1085
const std::string & GetHost() const
Fetch the task host name.
Definition path.hh:1080
virtual void SetBuffers(const Buffers &buffs)
Set the DRAMA path buffers.
Definition path.hh:1149
void SetParam(thread::TMessHandler *action, const std::string &name, const sds::Id &argIn, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
Sends a set parameter message to a task and blocks the current thread until it completes.
Definition path.hh:2146
bool KickWaitUntil(std::chrono::steady_clock::time_point until, thread::TMessHandler *action, const std::string &name, const sds::Id &argIn=sds::Id::CreateNullItem(), sds::IdPtr *const argOut=nullptr, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
Sends a kick message to a task and block the current thread until the reply is received or a timeout ...
Definition path.hh:1861
bool GetParamWaitUntil(std::chrono::steady_clock::time_point until, thread::TMessHandler *action, const std::string &name, sds::IdPtr *const argOut, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
Sends a get parameter message to a task and blocks the current thread until it completes.
Definition path.hh:2347
bool SetParamWaitUntil(std::chrono::steady_clock::time_point until, thread::TMessHandler *action, const std::string &name, const sds::Id &argIn, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
Sends a set parameter message to a task and blocks the current thread until it completes or a timeout...
Definition path.hh:2198
void GetParam(thread::TMessHandler *action, const std::string &name, sds::IdPtr *const argOut, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
Sends a get parameter message to a task and blocks the current thread until it completes.
Definition path.hh:2246
virtual bool Active() const
Indicate if a task is active.
Definition path.hh:1298
static void HandleDisconnected(const char *task, DitsPathType path, StatusType *status)
Handle task disconnection.
Path & operator=(Path &&rhs)=default
Move assignment operator.
void ObeyBulk(thread::TMessHandler *action, const std::string &name, BulkDataSds *argIn, unsigned notifyBytes=1024 *1024, sds::IdPtr *const argOut=nullptr, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
Sends an obey message to a task, with SDS bulk data argument, and blocks the current thread until the...
Definition path.hh:1631
virtual void Died()
Note that a task has died.
Definition path.hh:2577
bool GetPathLoaded() const
Indicate if a the task was loaded.
Definition path.hh:1061
virtual void ClearState()
Clear the task state.
Definition path.hh:1289
virtual void SetSymbols(const bool Flag=true)
Interpert file name as a symbol (VMS Target only)
Definition path.hh:1243
virtual bool Busy() const
Returns true if we can't send a message because path is busy.
Definition path.hh:1324
virtual bool Initial() const
Return true if a GetPath operation is required.
Definition path.hh:1313
virtual DitsPathType GetDitsPath(bool nothrow=false)
Return the underlying DITS path object.
bool KickBulkWaitUntil(std::chrono::steady_clock::time_point until, thread::TMessHandler *action, const std::string &name, BulkDataSds *argIn, unsigned notifyBytes=1024 *1024, sds::IdPtr *const argOut=nullptr, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
Sends a kick message to a task and block the current thread until the reply is received or a timeout ...
Definition path.hh:2122
virtual void Delete(int force)
Delete the task.
bool KickBulkWaitUntil(std::chrono::steady_clock::time_point until, thread::TMessHandler *action, const std::string &name, BulkData *argIn, bool isSds, unsigned notifyBytes=1024 *1024, sds::IdPtr *const argOut=nullptr, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
Sends a kick message to a task and block the current thread until the reply is received or a timeout ...
Definition path.hh:2044
bool GetParamWaitUntil(std::chrono::steady_clock::time_point until, thread::TMessHandler *action, const std::initializer_list< std::string > names, sds::IdPtr *const argOut, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
Sends a get parameter message to a task and blocks the current thread until it completes.
Definition path.hh:2407
bool ControlWaitUntil(std::chrono::steady_clock::time_point until, thread::TMessHandler *action, const std::string &name, const sds::Id &argIn=sds::Id::CreateNullItem(), sds::IdPtr *const argOut=nullptr, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
Sends a control message to a task and block the current thread until the reply is received or a timeo...
Definition path.hh:2523
static void SpawnKickArgUpdate(drama::sds::Id *arg, DitsTransIdType tid)
update an SDS argument structure for kicking a Spawned transaction
static drama::sds::Id SpawnKickArg(DitsTransIdType tid)
Create an SDS argument structure for kicking a Spawned transaction.
void KickBulk(thread::TMessHandler *action, const std::string &name, BulkDataSds *argIn, unsigned notifyBytes=1024 *1024, sds::IdPtr *const argOut=nullptr, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
Sends a kick message, with SDS bulk data argument, to a task and blocks the current thread until the ...
Definition path.hh:1988
virtual void SetFile(const std::string &File)
Set the executable file name.
Definition path.hh:1138
virtual std::shared_ptr< Task > GetTask() const
Get a reference to the DRAMA task we are part of.
Definition path.hh:1334
virtual void SetProcess(const std::string &ProcessName)
Set the process names.
virtual void GetPathImmed()
Get a path to a task if DITS already has it.
void Obey(thread::TMessHandler *action, const std::string &name, const sds::Id &argIn=sds::Id::CreateNullItem(), sds::IdPtr *const argOut=nullptr, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
Sends an obey message to a task and blocks the current thread until the action is complete.
Definition path.hh:1416
bool ObeyBulkWaitUntil(std::chrono::steady_clock::time_point until, thread::TMessHandler *action, const std::string &name, BulkDataSds *argIn, unsigned notifyBytes=1024 *1024, sds::IdPtr *const argOut=nullptr, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
Sends an obey message to a task, with a SDS bulk data argument, and blocks the current thread until t...
Definition path.hh:1770
Path(std::weak_ptr< Task > theTask, DitsPathType path)
Construct from existing DITS path.
virtual void SetArgument(const std::string &LoadArg, bool const Append=false)
Set the load time argument string.
virtual void SetName(const std::string &TaskName)
Set the task name.
virtual void SetProg(const bool Flag=true)
Interpert file name as a program name.
Definition path.hh:1266
virtual void SetNames(const bool Flag=true)
Insist that symbols known to IMP_Master be known to the task.
Definition path.hh:1225
static std::chrono::steady_clock::time_point DeltaToTimePoint(int secs)
Given a number of seconds, return a time point that number of seconds into the future.
Definition path.hh:1463
virtual bool IsDead() const
Return true if a previously active task has disconnected.
Definition path.hh:1306
void Control(thread::TMessHandler *action, const std::string &name, const sds::Id &argIn=sds::Id::CreateNullItem(), sds::IdPtr *const argOut=nullptr, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
Sends a control message to a task and blocks the current thread until the reply is received.
Definition path.hh:2462
virtual void LogLoad(const bool Flag=true)
Load use <a href="../routines/MsgOut.html">MsgOut()</a> a lines indicating the load operations.
Definition path.hh:1280
Path(std::weak_ptr< Task > theTask)
Path to self constructor.
void MonitorCancel(thread::TMessHandler *action, int monId, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
Send a Monitor Cancel message to a task and block until it is complete.
Definition path.hh:2783
void MonitorForward(thread::TMessHandler *action, const sds::Id &argIn, MessageEventHandler *const eventProcessor=&_simpleMonEventProcessor)
Send a Monitor Forward message to a task and block until it is complete.
Definition path.hh:2670
const std::string GetTaskName() const
Fetch the task name.
Path()
Construct a null object.
Definition path.hh:1040
virtual void SetStackSize(unsigned bytes)
Set the stack size for the load.
void GetPath(thread::TMessHandler *action, thread::TransEvtProcessor *const eventProcessor=&_getPathEventProcessor)
Get a path to a the task.
bool ObeyWaitUntil(std::chrono::steady_clock::time_point until, thread::TMessHandler *action, const std::string &name, const sds::Id &argIn=sds::Id::CreateNullItem(), sds::IdPtr *const argOut=nullptr, MessageEventHandler *const eventProcessor=&_simpleEventProcessor)
Sends an obey message to a task and blocks the current thread until the action is complete or a timeo...
Definition path.hh:1497
virtual void SetHost(const std::string &Host)
Set the task host name.
Definition path.hh:1111
A Class which provides access to DRAMA's message sending facilities.
Definition path.hh:689
std::lock_guard< mutexType > guardType
Defines the type of a lock guard using our mutex type.
Definition task.hh:471
static Id CreateArgCmdStruct(const ContainerType &values, const std::string &name="ArgStructure")
Factory constructor which creates a new "Arg" style SDS structure in the DRAMA Command style.
Definition sds.hh:3049
static Id CreateArgStruct(const std::string &name="ArgStructure")
Factory constructor which creates a new "Arg" style SDS structure.
static Id CreateNullItem()
Factory constructor method that constructs an null sds::Id item .
A C++ Interface to the handling SDS structures.
Definition sds.hh:428
A class with information used by the TransEvtProcessor methods.
Definition thread.hh:147
This interface class must be implemented by classes which have threads waiting for messages.
Definition thread.hh:308
DRAMA 2 main include file.
#define DramaTHROW_F(status_, format_,...)
Throw a Drama exception with fmt::format string formatting.
Definition exception.hh:129
std::shared_ptr< Id > IdPtr
A shared pointer for sds::Id items.
Definition sds.hh:3613
void CreateRunDramaTask()
Create and run a DRAMA task, with standard exception handling.
Definition task.hh:1339
std::chrono::steady_clock::time_point CreateFutureTimepoint(double secs)
Return a steady_clock time point suitable for use with the Path::...WaitUntil() methods based on an o...
Definition path.hh:94
@ Kick
Action has been kicked.
@ BulkTransferred
bulk data transferred message received
@ BulkDone
message received
@ Obey
Action has been obeyed.
std::vector< ErsMessageType > ErsMessageVector
A type used to return ERS messages.
Definition path.hh:180
The drama namespace contains all the classes, types etc of the DRAMA 2 implementation.
Definition drama.hh:99
StatusType entryStatus
Entry status value.
Definition task.hh:136
bool complete
IS transaction complete.
Definition task.hh:139
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.