ISAAC
Overview :: Library Doc :: Server Doc :: JSON Commands

In Situ Animation of Accelerated Computations

MessageAble.hpp
Go to the documentation of this file.
1 /* This file is part of ISAAC.
2  *
3  * ISAAC is free software: you can redistribute it and/or modify
4  * it under the terms of the GNU Lesser General Public License as
5  * published by the Free Software Foundation, either version 3 of the
6  * License, or (at your option) any later version.
7  *
8  * ISAAC is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with ISAAC. If not, see <www.gnu.org/licenses/>. */
15 
16 #pragma once
17 
18 #include "Common.hpp"
19 #include "ThreadList.hpp"
20 
21 template <typename MessageTemplate>
23 {
24  public:
25  virtual ~MessageAble()
26  {
27  MessageTemplate* mom;
28  while (mom = messagesIn.pop_front())
29  mom->suicide();
30  while (mom = messagesOut.pop_front())
31  mom->suicide();
32  }
33  //Called from MetaDataConnector / Client
34  errorCode clientSendMessage(MessageTemplate* message)
35  {
36  messagesOut.push_back(message);
37  }
38  MessageTemplate* clientGetMessage()
39  {
40  return messagesIn.pop_front();
41  }
42  //Called from Master
43  errorCode masterSendMessage(MessageTemplate* message)
44  {
45  messagesIn.push_back(message);
46  }
47  MessageTemplate* masterGetMessage()
48  {
49  return messagesOut.pop_front();
50  }
51  //protected:
52  ThreadList<MessageTemplate*> messagesIn; //From master to the client
53  ThreadList<MessageTemplate*> messagesOut; //From client to the master
54 };
MessageTemplate * clientGetMessage()
Definition: MessageAble.hpp:38
errorCode clientSendMessage(MessageTemplate *message)
Definition: MessageAble.hpp:34
MessageTemplate * masterGetMessage()
Definition: MessageAble.hpp:47
int errorCode
Definition: Common.hpp:24
ThreadList< MessageTemplate * > messagesIn
Definition: MessageAble.hpp:52
errorCode masterSendMessage(MessageTemplate *message)
Definition: MessageAble.hpp:43
ThreadList< MessageTemplate * > messagesOut
Definition: MessageAble.hpp:53
void push_back(T t)
Definition: ThreadList.hpp:45
virtual ~MessageAble()
Definition: MessageAble.hpp:25