-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathudp_consumer_task.hpp
73 lines (59 loc) · 1.87 KB
/
udp_consumer_task.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef VI_UDP_CONSUMER_TASK
#define VI_UDP_CONSUMER_TASK
#include "container_impl.h"
#include "udp_multicast_receiver.hpp"
#include "message_constants.h"
namespace vi
{
class udp_consumer_task
{
private:
container_hashset* mStorage;
container_queue* mQueue;
udp_multicast_receiver* mReceiver;
public:
udp_consumer_task(container_hashset* storage,
container_queue* queue,
udp_multicast_receiver* receiver) : mStorage(storage),
mQueue(queue),
mReceiver(receiver)
{
}
udp_consumer_task(const udp_consumer_task& other) : mStorage(other.mStorage),
mQueue(other.mQueue),
mReceiver(other.mReceiver)
{
}
udp_consumer_task& operator=(const udp_consumer_task& other)
{
if (this != &other)
{
mStorage = other.mStorage;
mQueue = other.mQueue;
mReceiver = other.mReceiver;
}
return *this;
}
void begin()
{
}
bool step()
{
Message m;
if (mReceiver->receive<Message>(m) == udp_multicast_receiver::receive_ok)
{
int entryStatus = mStorage->try_put(m.MessageId, m);
if (table_entry<Message>::empty == entryStatus &&
TARGET_DATA_VALUE == m.MessageData)
{
mQueue->push_head(m.MessageId);
}
}
return m.MessageType != TERMINATION_MESSAGE_TYPE;
}
void end()
{
}
};
};
#endif