View on GitHub

Vistle

Distributed Data-parallel Scientific Visualization in VR

messagequeue.h
Go to the documentation of this file.
1#ifndef MESSAGEQUEUE_H
2#define MESSAGEQUEUE_H
3
4#include <deque>
5#include <mutex>
7#define BOOST_INTERPROCESS_MSG_QUEUE_CIRCULAR_INDEX
8#include <boost/interprocess/ipc/message_queue.hpp>
9
10#include "message.h"
11#include "export.h"
12
13namespace vistle {
14namespace message {
15
16class Message;
17
19public:
20 typedef boost::interprocess::message_queue message_queue;
21
22 static MessageQueue *create(const std::string &m_name);
23 static MessageQueue *open(const std::string &m_name);
24
25 static std::string createName(const char *prefix, const int moduleID, const int rank);
26
27 void makeNonBlocking();
28
30
31 const std::string &getName() const;
32
33 bool send(const Message &msg);
34 bool progress();
35
36 void receive(Message &msg);
37 bool tryReceive(Message &msg);
38 size_t getNumMessages();
39
40private:
41 bool m_blocking;
42 MessageQueue(const std::string &m_name, boost::interprocess::create_only_t);
43 MessageQueue(const std::string &m_name, boost::interprocess::open_only_t);
44
45 const std::string m_name;
46 message_queue m_mq;
47 std::deque<message::Buffer> m_queue;
48 std::mutex m_mutex;
49};
50
51} // namespace message
52} // namespace vistle
53#endif
Definition: messagequeue.h:18
boost::interprocess::message_queue message_queue
Definition: messagequeue.h:20
Definition: message.h:157
#define V_COREEXPORT
Definition: export.h:9
std::string prefix(int argc, char *argv[])
Definition: directory.cpp:33
bool send(socket_t &sock, const message::Message &msg, error_code &ec, const char *payload, size_t size)
Definition: tcpmessage.cpp:447
Definition: allobjects.cpp:30