diff --git a/containers_cpp/include/embb/containers/internal/hazard_pointer-inl.h b/containers_cpp/include/embb/containers/internal/hazard_pointer-inl.h index 6d72bf2..7cbb74b 100644 --- a/containers_cpp/include/embb/containers/internal/hazard_pointer-inl.h +++ b/containers_cpp/include/embb/containers/internal/hazard_pointer-inl.h @@ -97,18 +97,18 @@ FixedSizeList::~FixedSizeList() { template< typename GuardType > bool HazardPointerThreadEntry::IsActive() { - return (is_active == 1); + return is_active; } template< typename GuardType > bool HazardPointerThreadEntry::TryReserve() { - int expected = 0; - return is_active.CompareAndSwap(expected, 1); + bool expected = false; + return is_active.CompareAndSwap(expected, true); } template< typename GuardType > void HazardPointerThreadEntry::Deactivate() { - is_active = 0; + is_active = false; } template< typename GuardType > @@ -198,10 +198,7 @@ GuardPointer(int guardNumber, GuardType pointerToGuard) { template< typename GuardType > void HazardPointerThreadEntry::SetActive(bool active) { - if (active == true) - is_active = 1; - else - is_active = 0; + is_active = active; } template< typename GuardType > diff --git a/containers_cpp/include/embb/containers/internal/hazard_pointer.h b/containers_cpp/include/embb/containers/internal/hazard_pointer.h index 9a63823..2fff100 100644 --- a/containers_cpp/include/embb/containers/internal/hazard_pointer.h +++ b/containers_cpp/include/embb/containers/internal/hazard_pointer.h @@ -201,7 +201,7 @@ class HazardPointerThreadEntry { * signal that it is leaving. If a thread has left, the other threads are * responsible for cleaning up its retired list. */ - embb::base::Atomic< int > is_active; + embb::base::Atomic< bool > is_active; /** * The guarded pointer of this thread, has size \c guard_per_thread. diff --git a/containers_cpp/include/embb/containers/internal/object_pool-inl.h b/containers_cpp/include/embb/containers/internal/object_pool-inl.h index d1af0ee..a8f5e3a 100644 --- a/containers_cpp/include/embb/containers/internal/object_pool-inl.h +++ b/containers_cpp/include/embb/containers/internal/object_pool-inl.h @@ -99,7 +99,7 @@ GetIndexOfObject(const T &obj) const { template T* ObjectPool::AllocateRaw() { - int val; + bool val; int allocated_index = p.Allocate(val); if (allocated_index == -1) { return NULL; @@ -128,7 +128,7 @@ void ObjectPool::Free(T* obj) { int index = GetIndexOfObject(*obj); obj->~T(); - p.Free(1, index); + p.Free(true, index); } template diff --git a/containers_cpp/include/embb/containers/lock_free_mpmc_queue.h b/containers_cpp/include/embb/containers/lock_free_mpmc_queue.h index b129812..16cce38 100644 --- a/containers_cpp/include/embb/containers/lock_free_mpmc_queue.h +++ b/containers_cpp/include/embb/containers/lock_free_mpmc_queue.h @@ -105,7 +105,7 @@ class LockFreeMPMCQueueNode { * which stores the elements. */ template< typename T, - typename ValuePool = embb::containers::LockFreeTreeValuePool < int, 0 > + typename ValuePool = embb::containers::LockFreeTreeValuePool < bool, false > > class LockFreeMPMCQueue { private: diff --git a/containers_cpp/include/embb/containers/lock_free_stack.h b/containers_cpp/include/embb/containers/lock_free_stack.h index 299f61e..3d1fbd8 100644 --- a/containers_cpp/include/embb/containers/lock_free_stack.h +++ b/containers_cpp/include/embb/containers/lock_free_stack.h @@ -170,7 +170,7 @@ class LockFreeStackNode { * which stores the elements. */ template< typename T, -typename ValuePool = embb::containers::LockFreeTreeValuePool < int, 0 > > +typename ValuePool = embb::containers::LockFreeTreeValuePool < bool, false > > class LockFreeStack { private: /** diff --git a/containers_cpp/include/embb/containers/object_pool.h b/containers_cpp/include/embb/containers/object_pool.h index bbc8765..b4e4b13 100644 --- a/containers_cpp/include/embb/containers/object_pool.h +++ b/containers_cpp/include/embb/containers/object_pool.h @@ -55,7 +55,7 @@ namespace containers { */ template, + embb::containers::WaitFreeArrayValuePool< bool, false >, class ObjectAllocator = embb::base::Allocator > class ObjectPool { private: @@ -87,9 +87,9 @@ class ObjectPool { class ReturningTrueIterator { public: typedef ReturningTrueIterator self_type; - typedef int value_type; - typedef int& reference; - typedef int* pointer; + typedef bool value_type; + typedef bool& reference; + typedef bool* pointer; typedef std::forward_iterator_tag iterator_category; typedef int difference_type; explicit ReturningTrueIterator(size_t count_value); @@ -102,7 +102,7 @@ class ObjectPool { private: size_t count_value; - int ret_value; + bool ret_value; }; bool IsContained(const T &obj) const; diff --git a/containers_cpp/test/main.cc b/containers_cpp/test/main.cc index bb4f8ce..9919444 100644 --- a/containers_cpp/test/main.cc +++ b/containers_cpp/test/main.cc @@ -63,8 +63,8 @@ PT_MAIN("Data Structures C++") { embb::containers::LockFreeStack >); PT_RUN(embb::containers::test::ObjectPoolTest - >); + >); PT_RUN(embb::containers::test::ObjectPoolTest - >); + >); }