ifw-ccf 5.0.2
Loading...
Searching...
No Matches
testManagerHelper.cpp
Go to the documentation of this file.
1
6
8public:
9 TestThread(const std::string& thread_name,
10 ifw::ccf::mptk::MessageBus& message_bus,
11 const double period = 0.1):
12 ifw::ccf::mptk::Thread(thread_name, message_bus, period) {
13 m_msg_count = 0;
14 };
15
17 // No special clean up to do here -- nothing was allocated etc ...
18 };
19
20 void UserLogic() {
21 std::map<std::string, std::string>
22 receiver_threads = {{"ThreadA", "ThreadB"}, {"ThreadB", "ThreadC"},
23 {"ThreadC", "ThreadD"}, {"ThreadD", "MainThread"}};
24 bool timed_out;
26 if (MsgBus().ReceiveMessage(GetName(), 1, timed_out, message)) {
27 std::string data = fmt::format("{}/{}. Data: {}", GetName().c_str(),
28 ++m_msg_count, message.Data().c_str());
30 receiver_threads[GetName()], data);
31 MsgBus().SendMessage(new_message);
32 }
33 };
34
35private:
36 int16_t m_msg_count;
37};
38
39
Definition testManagerHelper.cpp:7
TestThread(const std::string &thread_name, ifw::ccf::mptk::MessageBus &message_bus, const double period=0.1)
Definition testManagerHelper.cpp:9
void UserLogic()
User provided business logic. The UserLogic method need not execute an internal loop....
Definition testManagerHelper.cpp:20
~TestThread()
Definition testManagerHelper.cpp:16
IFW CTD Multiprocessing Toolkit Message Bus.
Definition messageBus.hpp:91
void SendMessage(const Message &message)
Send a message on the Message Bus.
Definition messageBus.cpp:82
IFW CTD Multiprocessing Toolkit Message class.
Definition message.hpp:24
const std::string & Data() const
Return data (payload) of message.
Definition message.cpp:89
IFW CTD Multiprocessing Toolkit Thread base class.
Definition thread.hpp:30
MessageBus & MsgBus()
Get acces to the MessageBus associated with this thread object.
Definition thread.cpp:279
std::string GetName() const
Return the thread Name.
Definition thread.cpp:72
Thread(const std::string &thread_name, MessageBus &message_bus, const double period=0.1)
Constructor method, setting up the internal members.
Definition thread.cpp:41
Definition appBase.cpp:9