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();
135 throw NotLockedException(
"Message queue must be locked to insert messages after iterator.");
137 if (it.cur == NULL) {
144 msg_list_t *l = (msg_list_t *)malloc(
sizeof(msg_list_t));
145 l->next = it.cur->next;
147 l->msg_id = msg->
id();
149 if (l->next == NULL) {
161 msg_list_t *l = list_;
162 msg_list_t *p = NULL;
182 msg_list_t *l = list_;
183 msg_list_t *p = NULL;
185 if (l->msg_id == msg_id) {
225 msg_list_t * l = list_;
242 bool rv = (list_ == NULL);
417 for (
unsigned int j = 0; (cur != NULL) && (j < i); ++j) {
432 for (
unsigned int j = 0; (cur != NULL) && (j < i); ++j) {
446 return (cur == c.cur);
457 return (cur != c.cur);
467 return (cur != NULL) ? cur->msg : NULL;
Base class for all messages passed through interfaces in Fawkes BlackBoard.
unsigned int id() const
Get message ID.
void mark_enqueued()
Mark message as being enqueued.
void insert_after(const MessageIterator &it, Message *msg)
Enqueue message after given iterator.
unsigned int id() const
Get ID of current element or 0 if element is end.
Message already enqueued exception.
MessageIterator & operator+=(unsigned int i)
Advance by a certain amount.
MessageIterator end()
Get iterator to element beyond end of message queue list.
Fawkes library namespace.
void unlock()
Unlock the mutex.
MessageQueue()
Constructor.
Message * operator*() const
Get memory pointer of chunk.
MessageAlreadyQueuedException()
Constructor.
A NULL pointer was supplied where not allowed.
MessageIterator()
Constructor.
bool enqueued() const
Check is message has been enqueued.
MessageIterator & operator+(unsigned int i)
Advance by a certain amount.
MessageIterator & operator++()
Increment iterator.
Base class for exceptions in Fawkes.
virtual ~MessageQueue()
Destructor.
void flush()
Delete all messages from queue.
bool operator!=(const MessageIterator &c) const
Check inequality of two iterators.
unsigned int size() const
Get number of messages in queue.
bool try_lock()
Try to lock message queue.
bool try_lock()
Tries to lock the mutex.
bool operator==(const MessageIterator &c) const
Check equality of two iterators.
Message * operator->() const
Act on current message.
MessageIterator begin()
Get iterator to first element in message queue.
void append(Message *msg)
Append message to queue.
bool empty() const
Check if message queue is empty.
void lock()
Lock this mutex.
Operation on unlocked object.
void remove(const Message *msg)
Remove message from queue.
void pop()
Erase first message from queue.
void unlock()
Unlock message queue.
Message * first()
Get first message from queue.
Mutex mutual exclusion lock.
void lock()
Lock message queue.
MessageIterator & operator=(const MessageIterator &c)
Assign iterator.