2 * Copyright 2005, Haiku.
3 * Distributed under the terms of the MIT License.
6 * Axel Dörfler, axeld@pinc-software.de
8 #ifndef MESSAGE_LOOPER_H
9 #define MESSAGE_LOOPER_H
17 class MessageLooper
: public BLocker
{
19 MessageLooper(const char* name
);
20 virtual ~MessageLooper();
25 status_t
PostMessage(int32 code
,
26 bigtime_t timeout
= B_INFINITE_TIMEOUT
);
28 thread_id
Thread() const { return fThread
; }
29 bool IsQuitting() const { return fQuitting
; }
30 sem_id
DeathSemaphore() const { return fDeathSemaphore
; }
32 virtual port_id
MessagePort() const = 0;
34 static status_t
WaitForQuit(sem_id semaphore
,
35 bigtime_t timeout
= B_INFINITE_TIMEOUT
);
38 virtual void _PrepareQuit();
39 virtual void _GetLooperName(char* name
, size_t length
);
40 virtual void _DispatchMessage(int32 code
, BPrivate::LinkReceiver
&link
);
41 virtual void _MessageLooper();
44 static int32
_message_thread(void *_looper
);
48 BPrivate::PortLink fLink
;
50 sem_id fDeathSemaphore
;
53 static const int32 kMsgQuitLooper
= 'quit';
55 #endif /* MESSAGE_LOOPER_H */