2 * Copyright 2005, Ingo Weinhold, bonefish@users.sf.net. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 #ifndef MESSAGING_SERVICE_H
7 #define MESSAGING_SERVICE_H
10 #include <MessagingServiceDefs.h>
12 // MessagingCommandHandler
13 class MessagingCommandHandler
{
15 MessagingCommandHandler();
16 virtual ~MessagingCommandHandler();
18 virtual void HandleMessagingCommand(uint32 command
, const void *data
,
27 static status_t
Create(area_id kernelAreaID
, sem_id lockSem
,
28 sem_id counterSem
, MessagingArea
*&area
);
36 int32
CountCommands() const;
37 const messaging_command
*PopCommand();
41 area_id
NextKernelAreaID() const;
42 void SetNextArea(MessagingArea
*area
);
43 MessagingArea
*NextArea() const;
48 messaging_area_header
*fHeader
;
52 sem_id fCounterSem
; // TODO: Remove, if not needed.
53 MessagingArea
*fNextArea
;
57 class MessagingService
{
65 static status_t
CreateDefault();
66 static void DeleteDefault();
67 static MessagingService
*Default();
69 void SetCommandHandler(uint32 command
, MessagingCommandHandler
*handler
);
72 MessagingCommandHandler
*_GetCommandHandler(uint32 command
) const;
74 static int32
_CommandProcessorEntry(void *data
);
75 int32
_CommandProcessor();
77 class DefaultSendCommandHandler
;
78 struct CommandHandlerMap
;
80 static MessagingService
*sService
;
82 mutable BLocker fLock
;
85 MessagingArea
*fFirstArea
;
86 CommandHandlerMap
*fCommandHandlers
;
87 thread_id fCommandProcessor
;
88 volatile bool fTerminating
;
91 #endif // MESSAGING_SERVICE_H