| | |
| | | public: |
| | | SharedQueue(const uint32_t len, Allocator<D> const &alloc) : |
| | | Super(len, alloc) {} |
| | | using Super::capacity; |
| | | using Super::size; |
| | | |
| | | template <class Iter, class OnWrite> |
| | | int TryWrite(Iter begin, Iter end, const OnWrite &onWrite) |
| | |
| | | |
| | | using namespace bhome_msg; |
| | | |
| | | class ShmMsgQueue : private ShmObject<SharedQueue<MsgI>>, public StaticDataRef<std::atomic<uint64_t>, ShmMsgQueue> |
| | | class ShmMsgQueue : public StaticDataRef<std::atomic<uint64_t>, ShmMsgQueue> |
| | | { |
| | | typedef ShmObject<SharedQueue<MsgI>> Super; |
| | | typedef Super::Data Queue; |
| | | typedef ShmObject<SharedQueue<MsgI>> Shmq; |
| | | typedef Shmq::ShmType ShmType; |
| | | typedef Shmq::Data Queue; |
| | | typedef std::function<void()> OnSend; |
| | | |
| | | public: |
| | |
| | | ~ShmMsgQueue(); |
| | | static bool Remove(SharedMemory &shm, const MQId id); |
| | | MQId Id() const { return id_; } |
| | | using Super::shm; |
| | | ShmType &shm() const { return queue_.shm(); } |
| | | |
| | | bool Recv(MsgI &msg, const int timeout_ms) { return data()->Read(msg, timeout_ms); } |
| | | bool TryRecv(MsgI &msg) { return data()->TryRead(msg); } |
| | | bool Recv(MsgI &msg, const int timeout_ms) { return queue_.data()->Read(msg, timeout_ms); } |
| | | bool TryRecv(MsgI &msg) { return queue_.data()->TryRead(msg); } |
| | | template <class OnData> |
| | | int TryRecvAll(OnData const &onData) { return data()->TryReadAll(onData); } |
| | | int TryRecvAll(OnData const &onData) { return queue_.data()->TryReadAll(onData); } |
| | | static Queue *Find(SharedMemory &shm, const MQId remote_id); |
| | | static bool TrySend(SharedMemory &shm, const MQId remote_id, const MsgI &msg, OnSend const &onsend = OnSend()); |
| | | template <class Iter> |
| | |
| | | |
| | | private: |
| | | MQId id_; |
| | | Shmq &queue() { return queue_; } |
| | | Shmq queue_; |
| | | }; |
| | | |
| | | } // namespace bhome_shm |