diff options
author | Mauro Sardara <msardara@cisco.com> | 2019-01-19 01:29:33 +0100 |
---|---|---|
committer | Mauro Sardara <msardara@cisco.com> | 2019-01-21 12:03:48 +0100 |
commit | 9e5f41ed6ebe64a789916794626485460078c420 (patch) | |
tree | d2ac3090026ec8929558e88eca533f8787a6ff0b /libtransport/src/hicn/transport/utils/object_pool.h | |
parent | d13d37534d9449dd54277af664310d5f957dc44a (diff) |
- Code style fix
- Improved vpp binary api interface
- Correction in object pool destructor
- Fix error in Memif Connector
Change-Id: Id1dd9219fc1ac0b3717ae019ebff17373bebc635
Signed-off-by: Mauro Sardara <msardara@cisco.com>
Diffstat (limited to 'libtransport/src/hicn/transport/utils/object_pool.h')
-rwxr-xr-x | libtransport/src/hicn/transport/utils/object_pool.h | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/libtransport/src/hicn/transport/utils/object_pool.h b/libtransport/src/hicn/transport/utils/object_pool.h index d4d8e18d6..c369f7e12 100755 --- a/libtransport/src/hicn/transport/utils/object_pool.h +++ b/libtransport/src/hicn/transport/utils/object_pool.h @@ -45,7 +45,11 @@ class ObjectPool { public: using Ptr = std::unique_ptr<T, ObjectDeleter>; - ObjectPool() {} + ObjectPool() : destructor_(false) {} + + ~ObjectPool() { + destructor_ = true; + } std::pair<bool, Ptr> get() { if (object_pool_.empty()) { @@ -60,7 +64,9 @@ class ObjectPool { void add(T *object) { utils::SpinLock::Acquire locked(object_pool_lock_); - object_pool_.emplace_back(makePtr(object)); + if (TRANSPORT_EXPECT_TRUE(!destructor_)) { + object_pool_.emplace_back(makePtr(object)); + } } Ptr makePtr(T *object) { return Ptr(object, ObjectDeleter(this)); } @@ -71,6 +77,7 @@ class ObjectPool { utils::SpinLock object_pool_lock_; std::deque<Ptr> object_pool_; + bool destructor_; }; } // namespace utils
\ No newline at end of file |