wangzhengquan
2020-07-20 f85c9b875b060681b51f57b15074ba1c7c9f5636
queue/include/shm_queue.h
@@ -6,6 +6,7 @@
#include "hashtable.h"
#include "lock_free_queue.h"
#include "logger_factory.h"
#include "shm_allocator.h"
// default Queue size
// #define LOCK_FREE_Q_DEFAULT_SIZE 16
@@ -46,7 +47,7 @@
protected:
    /// @brief the actual queue-> methods are forwarded into the real 
    ///        implementation
    LockFreeQueue<ELEM_T>* queue;
    LockFreeQueue<ELEM_T, SHM_Allocator>* queue;
private:
    /// @brief disable copy constructor declaring it private
@@ -60,7 +61,7 @@
    hashtable_t *hashtable = mm_get_hashtable();
    std::set<int>* keyset = hashtable_keyset(hashtable);
    std::set<int>::iterator keyItr;
     LockFreeQueue<ELEM_T>* mqueue;
     LockFreeQueue<ELEM_T, SHM_Allocator>* mqueue;
    bool found;
    for (keyItr = keyset->begin(); keyItr != keyset->end(); keyItr++) {
        found = false;
@@ -71,7 +72,7 @@
            }
        }
        if(!found) {
           mqueue = (LockFreeQueue<ELEM_T> *)hashtable_get(hashtable, *keyItr);
           mqueue = (LockFreeQueue<ELEM_T, SHM_Allocator> *)hashtable_get(hashtable, *keyItr);
           delete mqueue;
        }
    }
@@ -84,10 +85,10 @@
{
    hashtable_t *hashtable = mm_get_hashtable();
    queue = (LockFreeQueue<ELEM_T> *)hashtable_get(hashtable, key);
    queue = (LockFreeQueue<ELEM_T, SHM_Allocator> *)hashtable_get(hashtable, key);
    //LockFreeQueue<int, 10000> q;
    if (queue == NULL || (void *)queue == (void *)1) {
        queue = new LockFreeQueue<ELEM_T>(qsize);
        queue = new LockFreeQueue<ELEM_T, SHM_Allocator>(qsize);
        hashtable_put(hashtable,  key, (void *)queue);
    }
    queue->reference++;