From 056f71f24cefaf88f2a93714c6678c03ed5f1e0e Mon Sep 17 00:00:00 2001
From: zhangmeng <775834166@qq.com>
Date: 星期五, 02 七月 2021 16:54:33 +0800
Subject: [PATCH] fixed to adapt gcc-5.4 & glibc-2.25
---
src/shm_msg_queue.h | 36 ++++++++++++++++++------------------
1 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/src/shm_msg_queue.h b/src/shm_msg_queue.h
index f496f0f..6a4d7a4 100644
--- a/src/shm_msg_queue.h
+++ b/src/shm_msg_queue.h
@@ -18,38 +18,38 @@
#ifndef SHM_MSG_QUEUE_D847TQXH
#define SHM_MSG_QUEUE_D847TQXH
+#include "defs.h"
#include "msg.h"
#include "shm_queue.h"
using namespace bhome_shm;
using namespace bhome_msg;
-class ShmMsgQueue : public StaticDataRef<std::atomic<uint64_t>, ShmMsgQueue>
+class ShmMsgQueue
{
- typedef ShmObject<SharedQ63<4>> Shmq;
- // typedef ShmObject<SharedQueue<int64_t>> Shmq;
- typedef Shmq::ShmType ShmType;
- typedef Shmq::Data Queue;
- typedef std::function<void()> OnSend;
-
public:
+ typedef int64_t RawData;
+ typedef NamedShmObject<SharedQ63> Shmq;
+ typedef Shmq::Data Queue;
+ typedef Shmq::ShmType ShmType;
typedef uint64_t MQId;
- static MQId NewId();
-
- ShmMsgQueue(const MQId id, ShmType &segment, const int len);
- ShmMsgQueue(const MQId id, const bool create_or_else_find, ShmType &segment, const int len);
- ShmMsgQueue(ShmType &segment, const int len);
+ ShmMsgQueue(ShmType &segment, const MQId id, Mode mode);
+ ShmMsgQueue(const int64_t abs_addr, ShmType &segment, const MQId id);
~ShmMsgQueue();
- static bool Remove(SharedMemory &shm, const MQId id);
+ static bool Remove(ShmType &shm, const MQId id);
MQId Id() const { return id_; }
ShmType &shm() const { return queue_.shm(); }
+ int64_t AbsAddr() const { return queue_.offset(); }
- bool Recv(MsgI &msg, const int timeout_ms) { return queue().Read(msg.OffsetRef(), timeout_ms); }
- bool TryRecv(MsgI &msg) { return queue().TryRead(msg.OffsetRef()); }
- static Queue *Find(SharedMemory &shm, const MQId remote_id);
- static bool TrySend(SharedMemory &shm, const MQId remote_id, MsgI msg);
- bool TrySend(const MQId remote_id, const MsgI &msg) { return TrySend(shm(), remote_id, msg); }
+ // bool Recv(RawData &val, const int timeout_ms) { return queue().Read(val, timeout_ms); }
+ bool TryRecv(RawData &val) { return queue().TryRead(val); }
+
+ // bool Recv(MsgI &msg, const int timeout_ms) { return Recv(msg.OffsetRef(), timeout_ms); }
+ bool TryRecv(MsgI &msg) { return TryRecv(msg.OffsetRef()); }
+ static Queue *Find(ShmType &shm, const MQId remote);
+ static bool TrySend(ShmType &shm, const MQInfo &remote, const RawData val);
+ bool TrySend(const MQInfo &remote, const RawData val) { return TrySend(shm(), remote, val); }
private:
MQId id_;
--
Gitblit v1.8.0