2005-11-16 16:01:59 +03:00
|
|
|
/*
|
2007-01-25 20:08:16 +03:00
|
|
|
* Copyright 2001-2007, Haiku, Inc. All Rights Reserved.
|
2005-11-16 16:01:59 +03:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef _MESSAGE_QUEUE_H
|
|
|
|
#define _MESSAGE_QUEUE_H
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
|
2005-11-16 16:01:59 +03:00
|
|
|
#include <Locker.h>
|
|
|
|
#include <Message.h>
|
|
|
|
/* For convenience */
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
|
2005-11-16 16:01:59 +03:00
|
|
|
class BMessageQueue {
|
|
|
|
public:
|
|
|
|
BMessageQueue();
|
|
|
|
virtual ~BMessageQueue();
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2005-11-16 16:01:59 +03:00
|
|
|
void AddMessage(BMessage* message);
|
|
|
|
void RemoveMessage(BMessage* message);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2005-11-16 16:01:59 +03:00
|
|
|
int32 CountMessages() const;
|
|
|
|
bool IsEmpty() const;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2005-11-16 16:01:59 +03:00
|
|
|
BMessage* FindMessage(int32 index) const;
|
|
|
|
BMessage* FindMessage(uint32 what, int32 index = 0) const;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2005-11-16 16:01:59 +03:00
|
|
|
bool Lock();
|
|
|
|
void Unlock();
|
|
|
|
bool IsLocked() const;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2005-11-16 16:01:59 +03:00
|
|
|
BMessage *NextMessage();
|
2007-01-25 20:08:16 +03:00
|
|
|
bool IsNextMessage(const BMessage* message) const;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2005-11-16 16:01:59 +03:00
|
|
|
private:
|
|
|
|
// Reserved space in the vtable for future changes to BMessageQueue
|
|
|
|
virtual void _ReservedMessageQueue1();
|
|
|
|
virtual void _ReservedMessageQueue2();
|
|
|
|
virtual void _ReservedMessageQueue3();
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2005-11-16 16:01:59 +03:00
|
|
|
BMessageQueue(const BMessageQueue &);
|
|
|
|
BMessageQueue &operator=(const BMessageQueue &);
|
|
|
|
|
|
|
|
bool IsLocked();
|
|
|
|
// this needs to be exported for R5 compatibility and should
|
|
|
|
// be dropped as soon as possible
|
|
|
|
|
|
|
|
private:
|
|
|
|
BMessage* fHead;
|
|
|
|
BMessage* fTail;
|
|
|
|
int32 fMessageCount;
|
|
|
|
mutable BLocker fLock;
|
|
|
|
|
|
|
|
uint32 _reserved[3];
|
|
|
|
};
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2005-11-16 16:01:59 +03:00
|
|
|
#endif // _MESSAGE_QUEUE_H
|