From ea2ee85202f7b16d7b713bc7a7dcd1fa63bc6213 Mon Sep 17 00:00:00 2001 From: lichao <lichao@aiotlink.com> Date: 星期五, 26 三月 2021 11:54:50 +0800 Subject: [PATCH] change refcount to AddRef,Release interface. --- src/msg.cpp | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-) diff --git a/src/msg.cpp b/src/msg.cpp index 4ddb726..66eec4b 100644 --- a/src/msg.cpp +++ b/src/msg.cpp @@ -59,9 +59,18 @@ } -void Msg::FreeFrom(SharedMemory &shm) +int Msg::Release(SharedMemory &shm) const { + if (IsCounted()) { + const int n = count_->Dec(); + if (n != 0) { + return n; + } + } + // free data shm.Dealloc(ptr_); shm.Delete(count_); + return 0; } + } // namespace bhome_shm -- Gitblit v1.8.0