-
Notifications
You must be signed in to change notification settings - Fork 5
/
MessageQueue.h
38 lines (31 loc) · 889 Bytes
/
MessageQueue.h
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
// Copyright 2014-2015 the project authors as listed in the AUTHORS file.
// All rights reserved. Use of this source code is governed by the
// license that can be found in the LICENSE file.
#ifndef _MESSAGE_QUEUE
#define _MESSAGE_QUEUE
#include <stdint.h>
#define MAX_MESSAGES 16
#define MAX_MESSAGE_TEXT_LENGTH 64
typedef struct Message {
void* device;
int type;
long timestamp;
unsigned long code;
float value;
uint64_t longCode;
char text[MAX_MESSAGE_TEXT_LENGTH];
Message* next;
} Message;
class MessageQueue {
private:
Message messages[MAX_MESSAGES];
Message* newMessages;
Message* freeMessages;
public:
MessageQueue(void);
Message* getFreeMessage(void);
void enqueueMessage(Message* message);
Message* dequeueMessages(void);
void returnMessages(Message* messages, Message* lastMessage);
};
#endif