queue/include/array_lock_free_queue.h | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
queue/include/lock_free_queue.h | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
queue/include/shm_allocator.h | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
queue/libshm_queue.a | 补丁 | 查看 | 原始文档 | blame | 历史 | |
queue/socket.cb | 补丁 | 查看 | 原始文档 | blame | 历史 | |
test/Makefile | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
test/multiple_queue_consumer | 补丁 | 查看 | 原始文档 | blame | 历史 | |
test/multiple_queue_productor | 补丁 | 查看 | 原始文档 | blame | 历史 | |
test/single_consumer | 补丁 | 查看 | 原始文档 | blame | 历史 | |
test/single_productor | 补丁 | 查看 | 原始文档 | blame | 历史 | |
test/test_lockfree_queue | 补丁 | 查看 | 原始文档 | blame | 历史 | |
test/test_lockfree_queue.c | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
test/test_lostdata | 补丁 | 查看 | 原始文档 | blame | 历史 | |
test/test_queue | 补丁 | 查看 | 原始文档 | blame | 历史 | |
test/test_timeout | 补丁 | 查看 | 原始文档 | blame | 历史 |
queue/include/array_lock_free_queue.h
@@ -94,7 +94,7 @@ ,m_count(0) // #endif { m_theQueue = (ELEM_T*)Allocator::malloc(Q_SIZE * sizeof(ELEM_T)); m_theQueue = (ELEM_T*)Allocator::allocate(Q_SIZE * sizeof(ELEM_T)); } @@ -102,7 +102,7 @@ ArrayLockFreeQueue<ELEM_T, Allocator>::~ArrayLockFreeQueue() { // std::cout << "destroy ArrayLockFreeQueue\n"; Allocator::free(m_theQueue); Allocator::deallocate(m_theQueue); } queue/include/lock_free_queue.h
@@ -73,20 +73,17 @@ class LockFreeQueue { template < typename ELEM_T_ > friend class SHMQueue; private: int slots; int items; protected: LockFreeQueue(size_t qsize = LOCK_FREE_Q_DEFAULT_SIZE); public: LockFreeQueue(size_t qsize = LOCK_FREE_Q_DEFAULT_SIZE); /// @brief destructor of the class. /// Note it is not virtual since it is not expected to inherit from this /// template ~LockFreeQueue(); public: std::atomic_uint reference; /// @brief constructor of the class @@ -337,7 +334,7 @@ typename Allocator, template <typename T, typename AT> class Q_TYPE> void * LockFreeQueue<ELEM_T, Allocator, Q_TYPE>::operator new(size_t size){ return Allocator::malloc(size); return Allocator::allocate(size); } template < @@ -345,7 +342,7 @@ typename Allocator, template <typename T, typename AT> class Q_TYPE> void LockFreeQueue<ELEM_T, Allocator, Q_TYPE>::operator delete(void *p) { return Allocator::free(p); return Allocator::deallocate(p); } // include implementation files queue/include/shm_allocator.h
@@ -65,11 +65,13 @@ class SHM_Allocator { public: static void *malloc (size_t size) { static void *allocate (size_t size) { printf("shm_allocator malloc\n"); return mm_malloc(size); } static void free (void *ptr) { static void deallocate (void *ptr) { printf("shm_allocator free\n"); return mm_free(ptr); } }; @@ -77,11 +79,13 @@ class DM_Allocator { public: static void *malloc (size_t size) { static void *allocate (size_t size) { printf("dm_allocator malloc\n"); return malloc(size); } static void free (void *ptr) { static void deallocate (void *ptr) { printf("dm_allocator free\n"); return free(ptr); } }; queue/libshm_queue.aBinary files differ
queue/socket.cb
test/Makefile
@@ -14,7 +14,7 @@ include $(ROOT)/Make.defines.$(PLATFORM) PROGS = test_queue single_productor single_consumer multiple_queue_productor multiple_queue_consumer test_timeout test_lostdata PROGS = test_queue single_productor single_consumer multiple_queue_productor multiple_queue_consumer test_timeout test_lostdata test_lockfree_queue build: $(PROGS) test/multiple_queue_consumerBinary files differ
test/multiple_queue_productorBinary files differ
test/single_consumerBinary files differ
test/single_productorBinary files differ
test/test_lockfree_queueBinary files differ
test/test_lockfree_queue.c
New file @@ -0,0 +1,18 @@ #include "test.h" #include "shm_allocator.h" void test() { LockFreeQueue<int, DM_Allocator> *queue = new LockFreeQueue<int, DM_Allocator>(16); queue->push(12); int a; queue->pop(a); printf("%d\n", a); delete queue; } int main() { test(); std::cin.get(); } test/test_lostdataBinary files differ
test/test_queueBinary files differ
test/test_timeoutBinary files differ