| | |
| | | return pshm; |
| | | } |
| | | |
| | | struct Meta { |
| | | static const uint32_t kMsgTag = 0xf1e2d3c4; |
| | | typedef struct { |
| | | RefCount count_; |
| | | }; |
| | | const uint32_t tag_ = kMsgTag; |
| | | } Meta; |
| | | Offset offset_; |
| | | void *Alloc(const size_t size) |
| | | { |
| | |
| | | explicit ShmMsg(const size_t size) : |
| | | ShmMsg(Alloc(size)) {} |
| | | void swap(ShmMsg &a) { std::swap(offset_, a.offset_); } |
| | | bool valid() const { return static_cast<bool>(offset_); } |
| | | bool valid() const { return static_cast<bool>(offset_) && meta()->tag_ == kMsgTag; } |
| | | |
| | | // AddRef and Release works for both counted and not counted msg. |
| | | int AddRef() const { return valid() ? meta()->count_.Inc() : 1; } |
| | | int Release() |
| | | { |