Change IPC to exchange data, not pointers.

This commit is contained in:
Jared Boone 2015-08-20 13:13:12 -07:00
parent f99016d78f
commit 4126f1ab1f
7 changed files with 76 additions and 126 deletions

View file

@ -29,9 +29,15 @@
class MessageQueue {
public:
bool push(Message* const message);
template<typename T>
bool push(const T& message) {
static_assert(sizeof(T) <= Message::MAX_SIZE, "Message::MAX_SIZE too small for message type");
static_assert(std::is_base_of<Message, T>::value, "type is not based on Message");
Message* pop();
return push(&message, sizeof(message));
}
size_t pop(void* const buf, const size_t len);
size_t len() const {
return fifo.len();
@ -42,9 +48,10 @@ public:
}
private:
FIFO<Message*, 8> fifo;
FIFO<uint8_t, 11> fifo;
bool push(const void* const buf, const size_t len);
bool enqueue(Message* const message);
void signal();
};