1 /* 2 * Copyright 2001-2007, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _MESSAGE_QUEUE_H 6 #define _MESSAGE_QUEUE_H 7 8 9 #include <Locker.h> 10 #include <Message.h> 11 /* For convenience */ 12 13 14 class BMessageQueue { 15 public: 16 BMessageQueue(); 17 virtual ~BMessageQueue(); 18 19 void AddMessage(BMessage* message); 20 void RemoveMessage(BMessage* message); 21 22 int32 CountMessages() const; 23 bool IsEmpty() const; 24 25 BMessage* FindMessage(int32 index) const; 26 BMessage* FindMessage(uint32 what, int32 index = 0) const; 27 28 bool Lock(); 29 void Unlock(); 30 bool IsLocked() const; 31 32 BMessage *NextMessage(); 33 bool IsNextMessage(const BMessage* message) const; 34 35 private: 36 // Reserved space in the vtable for future changes to BMessageQueue 37 virtual void _ReservedMessageQueue1(); 38 virtual void _ReservedMessageQueue2(); 39 virtual void _ReservedMessageQueue3(); 40 41 BMessageQueue(const BMessageQueue &); 42 BMessageQueue &operator=(const BMessageQueue &); 43 44 bool IsLocked(); 45 // this needs to be exported for R5 compatibility and should 46 // be dropped as soon as possible 47 48 private: 49 BMessage* fHead; 50 BMessage* fTail; 51 int32 fMessageCount; 52 mutable BLocker fLock; 53 54 uint32 _reserved[3]; 55 }; 56 57 #endif // _MESSAGE_QUEUE_H 58