Skip to content

Commit

Permalink
refactor IO using mqueue
Browse files Browse the repository at this point in the history
  • Loading branch information
Octavian-Zhang committed Feb 23, 2022
1 parent d305ae5 commit 17a52ff
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 785 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ CMakeSettings.json
.vs/
.vscode/
log/
runtime/
runtime/
*.bak
23 changes: 0 additions & 23 deletions MissionApp/include/AlgoWrapper.h

This file was deleted.

11 changes: 0 additions & 11 deletions MissionApp/include/MW_ert_main.h

This file was deleted.

67 changes: 0 additions & 67 deletions MissionApp/include/MissionCircleFormation.h

This file was deleted.

55 changes: 0 additions & 55 deletions MissionApp/include/MissionData.h

This file was deleted.

53 changes: 53 additions & 0 deletions MissionApp/include/msgQueue.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// This class manages POSIX mqueue creation and destruction

#ifndef MSG_QUEUE
#define MSG_QUEUE

#include <stdio.h>
#include <cstdlib>
#include <mqueue.h>

class msgQueue
{
private:
mqd_t MQ_;
const char *qName_;

public:
msgQueue(const char *, int, int, int);
const mqd_t getMQ() { return MQ_; }
int getAttr(struct mq_attr *attr) { return mq_getattr(MQ_, attr); }
~msgQueue();
};

msgQueue::msgQueue(const char *name, int flags, int maxmsg, int msgsize) : qName_{name}
{
struct mq_attr attr;
attr.mq_flags = 0; /* Flags (ignored for mq_open()) */
attr.mq_maxmsg = maxmsg;
attr.mq_msgsize = msgsize;

MQ_ = mq_open(qName_, flags, 0664, &attr);

if (this->MQ_ < 0)
{
printf("mq_open failed\n");
exit(1);
}
}

msgQueue::~msgQueue()
{
if (mq_close(MQ_) < 0)
{
printf("mq_close failed\n");
exit(1);
}
if (mq_unlink(qName_) < 0)
{
printf("mq_unlink failed\n");
exit(1);
}
}

#endif
166 changes: 0 additions & 166 deletions MissionApp/include/protocol.h

This file was deleted.

Loading

0 comments on commit 17a52ff

Please sign in to comment.