24#include <core/exceptions/software.h>
25#include <core/threading/mutex.h>
26#include <interface/message.h>
27#include <interface/message_queue.h>
43:
Exception(
"Message already enqueued in another MessageQueue.")
78 msg_list_t *l = list_;
104 list_ = (msg_list_t *)malloc(
sizeof(msg_list_t));
107 list_->msg_id = msg->
id();
110 msg_list_t *l = (msg_list_t *)malloc(
sizeof(msg_list_t));
113 l->msg_id = msg->
id();
134 throw NotLockedException(
"Message queue must be locked to insert messages after iterator.");
136 if (it.cur == NULL) {
143 msg_list_t *l = (msg_list_t *)malloc(
sizeof(msg_list_t));
144 l->next = it.cur->next;
146 l->msg_id = msg->
id();
148 if (l->next == NULL) {
160 msg_list_t *l = list_;
161 msg_list_t *p = NULL;
181 msg_list_t *l = list_;
182 msg_list_t *p = NULL;
184 if (l->msg_id == msg_id) {
224 msg_list_t * l = list_;
241 bool rv = (list_ == NULL);
416 for (
unsigned int j = 0; (cur != NULL) && (j < i); ++j) {
431 for (
unsigned int j = 0; (cur != NULL) && (j < i); ++j) {
445 return (cur == c.cur);
456 return (cur != c.cur);
467 return (cur != NULL) ? cur->msg : NULL;
Base class for exceptions in Fawkes.
Message already enqueued exception.
MessageAlreadyQueuedException()
Constructor.
Message * operator->() const
Act on current message.
MessageIterator()
Constructor.
MessageIterator & operator+(unsigned int i)
Advance by a certain amount.
MessageIterator & operator++()
Increment iterator.
bool operator==(const MessageIterator &c) const
Check equality of two iterators.
bool operator!=(const MessageIterator &c) const
Check inequality of two iterators.
Message * operator*() const
Get memory pointer of chunk.
MessageIterator & operator+=(unsigned int i)
Advance by a certain amount.
MessageIterator & operator=(const MessageIterator &c)
Assign iterator.
unsigned int id() const
Get ID of current element or 0 if element is end.
MessageIterator end()
Get iterator to element beyond end of message queue list.
void append(Message *msg)
Append message to queue.
MessageQueue()
Constructor.
void unlock()
Unlock message queue.
void pop()
Erase first message from queue.
void flush()
Delete all messages from queue.
void lock()
Lock message queue.
void remove(const Message *msg)
Remove message from queue.
bool empty() const
Check if message queue is empty.
MessageIterator begin()
Get iterator to first element in message queue.
virtual ~MessageQueue()
Destructor.
bool try_lock()
Try to lock message queue.
void insert_after(const MessageIterator &it, Message *msg)
Enqueue message after given iterator.
unsigned int size() const
Get number of messages in queue.
Message * first()
Get first message from queue.
Base class for all messages passed through interfaces in Fawkes BlackBoard.
void mark_enqueued()
Mark message as being enqueued.
bool enqueued() const
Check is message has been enqueued.
unsigned int id() const
Get message ID.
Mutex mutual exclusion lock.
bool try_lock()
Tries to lock the mutex.
void lock()
Lock this mutex.
void unlock()
Unlock the mutex.
Operation on unlocked object.
A NULL pointer was supplied where not allowed.
Fawkes library namespace.