-
Notifications
You must be signed in to change notification settings - Fork 2
/
MarketQueue.cpp
70 lines (60 loc) · 1.39 KB
/
MarketQueue.cpp
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
#include "IPCMarketQueue.hpp"
#include <thread>
#include <sys/time.h>
#include <time.h>
struct TMarketData
{
char Colo[16];
int Tick;
char UpdateTime[32];
char Data[4096];
};
class MarketQueue
{
public:
explicit MarketQueue(unsigned int TickCount, unsigned int IPCKey): m_MarketQueue(TickCount, IPCKey)
{
}
bool Write(unsigned int index, const TMarketData& value)
{
return m_MarketQueue.Write(index, value);
}
bool Read(unsigned int index, TMarketData& value)
{
return m_MarketQueue.Read(index, value);
}
bool ReadLast(TMarketData& value)
{
return m_MarketQueue.ReadLast(value);
}
protected:
Utils::IPCMarketQueue<TMarketData> m_MarketQueue;
};
extern "C"
{
MarketQueue* MarketQueue_New(unsigned int TickCount, unsigned int IPCKey)
{
return new MarketQueue(TickCount, IPCKey);
}
bool MarketQueue_Write(MarketQueue* queue, unsigned int index, const TMarketData& value)
{
return queue->Write(index, value);
}
bool MarketQueue_Read(MarketQueue* queue, unsigned int index, TMarketData& value)
{
return queue->Read(index, value);
}
bool MarketQueue_ReadLast(MarketQueue* queue, TMarketData& value)
{
return queue->ReadLast(value);
}
void MarketQueue_Delete(MarketQueue* queue)
{
if(queue)
{
delete queue;
queue = NULL;
}
}
}
// g++ -fPIC -shared MarketQueue.cpp -o libMarketQueue.so