e18e5e44f4991da763655a996dc2ae1b529438bf
[iot2.git] / iotjava / iotrmi / C++ / ConcurrentLinkedListQueue.hpp
1 #ifndef _CONCURRENTLINKEDLISTQUEUE_HPP__
2 #define _CONCURRENTLINKEDLISTQUEUE_HPP__
3 #include <iostream>
4 #include <mutex>
5
6 /** Class ConcurrentLinkedListQueue is a queue that can handle
7  *  concurrent requests and packets for IoT communication via socket.
8  *  <p>
9  *  It stores object through a void pointer.
10  *
11  * @author      Rahmadi Trimananda <rtrimana @ uci.edu>
12  * @version     1.0
13  * @since       2017-01-27
14  */
15
16 using namespace std;
17
18 mutex mtx;
19
20 class Node {
21
22         private:
23                 Node* next;
24                 void* value;
25
26         public:
27                 Node(void* val);
28                 ~Node();
29                 void* getValue();
30                 Node* getNext();
31                 void setNext(Node* nxt);
32
33 };
34
35
36 class ConcurrentLinkedListQueue {
37
38         private:
39                 Node* tail;
40                 Node* head;
41
42         public:
43                 ConcurrentLinkedListQueue();
44                 ~ConcurrentLinkedListQueue();
45                 void enqueue(void* value);      // Enqueue to tail
46                 void* dequeue();                        // Dequeue from tail
47 };
48 #endif