demo/pub_sub | 补丁 | 查看 | 原始文档 | blame | 历史 | |
demo/queue | 补丁 | 查看 | 原始文档 | blame | 历史 | |
demo/req_rep | 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/libshm_queue.a | 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/queue/hashtable.c | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/queue/include/lock_free_queue.h | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/queue/include/shm_queue.h | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/queue/mm.c | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
test_socket/dgram_mod_req_rep | 补丁 | 查看 | 原始文档 | blame | 历史 | |
test_socket/dgram_socket_test | 补丁 | 查看 | 原始文档 | blame | 历史 |
demo/pub_subBinary files differ
demo/queueBinary files differ
demo/req_repBinary files differ
src/libshm_queue.aBinary files differ
src/queue/hashtable.c
@@ -91,9 +91,12 @@ size_t code = hashcode(key); tailq_entry_t *item; void *oldvalue; SemUtil::dec(hashtable->wlock); tailq_header_t *my_tailq_head = hashtable->array[code] ; if ( my_tailq_head == NULL) { SemUtil::inc(hashtable->wlock); return NULL; } else @@ -108,11 +111,12 @@ /* mm_free the item as we don't need it anymore. */ mm_free(item); SemUtil::inc(hashtable->wlock); return oldvalue; } } } SemUtil::inc(hashtable->wlock); return NULL; } @@ -124,6 +128,7 @@ void hashtable_removeall(hashtable_t *hashtable) { tailq_entry_t *item; SemUtil::dec(hashtable->wlock); for (int i = 0; i < MAPSIZE; i++) { tailq_header_t *my_tailq_head = hashtable->array[i] ; @@ -139,6 +144,7 @@ mm_free(my_tailq_head); hashtable->array[i] = NULL; } SemUtil::inc(hashtable->wlock); } /** src/queue/include/lock_free_queue.h
@@ -78,7 +78,7 @@ int items; public: // int mutex; int mutex; LockFreeQueue(size_t qsize = LOCK_FREE_Q_DEFAULT_SIZE); /// @brief destructor of the class. @@ -151,7 +151,7 @@ // std::cout << "LockFreeQueue init reference=" << reference << std::endl; slots = SemUtil::get(IPC_PRIVATE, qsize); items = SemUtil::get(IPC_PRIVATE, 0); // mutex = SemUtil::get(IPC_PRIVATE, 1); mutex = SemUtil::get(IPC_PRIVATE, 1); } template < @@ -163,6 +163,7 @@ LoggerFactory::getLogger().debug("LockFreeQueue desctroy"); SemUtil::remove(slots); SemUtil::remove(items); SemUtil::remove(mutex); } template < src/queue/include/shm_queue.h
@@ -6,7 +6,7 @@ #include "lock_free_queue.h" #include "logger_factory.h" #include "shm_allocator.h" #include "sem_util.h" // default Queue size // #define LOCK_FREE_Q_DEFAULT_SIZE 16 @@ -97,6 +97,7 @@ template < typename ELEM_T > SHMQueue<ELEM_T>::~SHMQueue() { SemUtil::dec( queue->mutex); queue->reference--; LoggerFactory::getLogger().debug("SHMQueue destructor reference===%d", queue->reference.load()); if(queue->reference.load() == 0) { @@ -104,7 +105,10 @@ hashtable_t *hashtable = mm_get_hashtable(); hashtable_remove(hashtable, KEY); LoggerFactory::getLogger().debug("SHMQueue destructor delete queue"); } else { SemUtil::inc(queue->mutex); } } template < typename ELEM_T > src/queue/mm.c
@@ -81,7 +81,7 @@ static void *place(void *bp, size_t size); static void *find_fit(size_t size); static void *coalesce(void *bp); static void rm_fblock(void *bp); static inline void rm_fblock(void *bp); static void insert_fblock (void *bp); static void *mem_sbrk(int incr); @@ -444,9 +444,12 @@ /** * remove a block form free list */ static void rm_fblock(void *rbp) static inline void rm_fblock(void *rbp) { // the successor of the previous block of rbp point to next block of rbp // err_msg(0, "SUCCRP(PREV_FBLKP(rbp) %p\n", SUCCRP(PREV_FBLKP(rbp)) ); // err_msg(0, "NEXT_FBLKP(rbp)%p\n", NEXT_FBLKP(rbp) ); PUT_PTR(SUCCRP(PREV_FBLKP(rbp)), NEXT_FBLKP(rbp)); // the predecessor of then next block of rbp point to previous block of rbp PUT_PTR(PREDRP(NEXT_FBLKP(rbp)), PREV_FBLKP(rbp)); test_socket/dgram_mod_req_repBinary files differ
test_socket/dgram_socket_testBinary files differ