Fawkes API
Fawkes Development Version
|
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;
void lock()
Lock this mutex.
bool empty() const
Check if message queue is empty.
MessageIterator & operator+=(unsigned int i)
Advance by a certain amount.
MessageIterator()
Constructor.
bool enqueued() const
Check is message has been enqueued.
bool try_lock()
Try to lock message queue.
void flush()
Delete all messages from queue.
Mutex mutual exclusion lock.
Base class for all messages passed through interfaces in Fawkes BlackBoard.
MessageAlreadyQueuedException()
Constructor.
void mark_enqueued()
Mark message as being enqueued.
void lock()
Lock message queue.
void pop()
Erase first message from queue.
void unlock()
Unlock message queue.
Operation on unlocked object.
void unlock()
Unlock the mutex.
unsigned int id() const
Get ID of current element or 0 if element is end.
unsigned int size() const
Get number of messages in queue.
Message * operator->() const
Act on current message.
MessageIterator end()
Get iterator to element beyond end of message queue list.
Fawkes library namespace.
void append(Message *msg)
Append message to queue.
MessageIterator & operator++()
Increment iterator.
void remove(const Message *msg)
Remove message from queue.
Message * first()
Get first message from queue.
void insert_after(const MessageIterator &it, Message *msg)
Enqueue message after given iterator.
MessageIterator & operator+(unsigned int i)
Advance by a certain amount.
virtual ~MessageQueue()
Destructor.
bool operator!=(const MessageIterator &c) const
Check inequality of two iterators.
bool try_lock()
Tries to lock the mutex.
MessageQueue()
Constructor.
MessageIterator & operator=(const MessageIterator &c)
Assign iterator.
unsigned int id() const
Get message ID.
A NULL pointer was supplied where not allowed.
Message already enqueued exception.
MessageIterator begin()
Get iterator to first element in message queue.
bool operator==(const MessageIterator &c) const
Check equality of two iterators.
Message * operator*() const
Get memory pointer of chunk.
Base class for exceptions in Fawkes.