FreeNOS
|
Template class which serves incoming messages from Channels using MessageHandlers. More...
#include <ChannelServer.h>
Public Types | |
enum | Result { Success, InvalidArgument, InvalidSize, IOError } |
Result codes. More... | |
Public Member Functions | |
ChannelServer (Base *inst) | |
Constructor function. More... | |
virtual | ~ChannelServer () |
Destructor function. More... | |
int | run () |
Enters an infinite loop, serving incoming requests. More... | |
void | setTimeout (const uint msec) |
Set a sleep timeout. More... | |
Protected Types | |
typedef void(Base::* | IPCHandlerFunction) (MsgType *) |
Member function pointer inside Base, to handle IPC messages. More... | |
typedef void(Base::* | IRQHandlerFunction) (Size) |
Member function pointer inside Base, to handle interrupts. More... | |
Protected Member Functions | |
void | addIPCHandler (const Size slot, IPCHandlerFunction h, const bool sendReply=true) |
Register a new IPC message action handler. More... | |
void | addIRQHandler (const Size slot, IRQHandlerFunction h) |
Register a new IRQ message vector handler. More... | |
virtual void | timeout () |
Called when sleep timeout is reached. More... | |
virtual bool | retryRequests () |
Retry any pending requests. More... | |
virtual void | onProcessTerminated (const ProcessID pid) |
Called whenever another Process is terminated. More... | |
void | retryAllRequests () |
Keep retrying requests until all served. More... | |
Protected Attributes | |
Base * | m_instance |
Server object instance. More... | |
ChannelClient * | m_client |
Client for sending replies. More... | |
ChannelRegistry & | m_registry |
Contains registered channels. More... | |
MemoryChannel | m_kernelEvent |
Kernel event channel. More... | |
Index< MessageHandler< IPCHandlerFunction >, MaximumHandlerCount > | m_ipcHandlers |
IPC handler functions. More... | |
Index< MessageHandler< IRQHandlerFunction >, MaximumHandlerCount > | m_irqHandlers |
IRQ handler functions. More... | |
ProcessID | m_self |
ProcessID of ourselves. More... | |
Timer::Info | m_time |
System timer value. More... | |
Timer::Info | m_expiry |
System timer expiration value. More... | |
Private Member Functions | |
void | processAll () |
Process all current events and channels. More... | |
void | sleepUntilWakeup () |
Let this process sleep until more events are raised. More... | |
Result | accept (const ProcessID pid, const Memory::Range range, const bool hardReset=true) |
Accept new channel connection. More... | |
void | recoverChannels () |
Read existing shares to recover MemoryChannels after restart. More... | |
Result | readKernelEvents () |
Read and process kernel events. More... | |
Result | readChannels () |
Read each Channel for messages. More... | |
Static Private Attributes | |
static const Size | MaximumHandlerCount = 255u |
Maximum number of IPC/IRQ handlers. More... | |
Template class which serves incoming messages from Channels using MessageHandlers.
MsgType | Type of Message to serve. |
Definition at line 79 of file ChannelServer.h.
|
protected |
Member function pointer inside Base, to handle IPC messages.
Definition at line 89 of file ChannelServer.h.
|
protected |
Member function pointer inside Base, to handle interrupts.
Definition at line 92 of file ChannelServer.h.
enum ChannelServer::Result |
Result codes.
Enumerator | |
---|---|
Success | |
InvalidArgument | |
InvalidSize | |
IOError |
Definition at line 99 of file ChannelServer.h.
|
inline |
Constructor function.
Definition at line 112 of file ChannelServer.h.
|
inlinevirtual |
Destructor function.
Definition at line 150 of file ChannelServer.h.
|
inlineprivate |
Accept new channel connection.
pid | ProcessID |
range | Memory range of shared mapping |
hardReset | True if the channel contents should be reset to initial state. |
Definition at line 314 of file ChannelServer.h.
Referenced by ChannelServer< DatastoreServer, DatastoreMessage >::readKernelEvents(), and ChannelServer< DatastoreServer, DatastoreMessage >::recoverChannels().
|
inlineprotected |
Register a new IPC message action handler.
slot | Action value to trigger h. |
h | Handler to execute. |
sendReply | True if the handler needs to send a reply |
Definition at line 203 of file ChannelServer.h.
|
inlineprotected |
Register a new IRQ message vector handler.
slot | Vector value to trigger h. |
h | Handler to execute. |
Definition at line 214 of file ChannelServer.h.
|
inlineprotectedvirtual |
Called whenever another Process is terminated.
pid | ProcessID of the terminating process |
Reimplemented in NetworkServer.
Definition at line 244 of file ChannelServer.h.
Referenced by ChannelServer< DatastoreServer, DatastoreMessage >::readKernelEvents().
|
inlineprivate |
Process all current events and channels.
Definition at line 262 of file ChannelServer.h.
Referenced by ChannelServer< DatastoreServer, DatastoreMessage >::run().
|
inlineprivate |
Read each Channel for messages.
Definition at line 464 of file ChannelServer.h.
Referenced by ChannelServer< DatastoreServer, DatastoreMessage >::processAll().
|
inlineprivate |
Read and process kernel events.
Definition at line 390 of file ChannelServer.h.
Referenced by ChannelServer< DatastoreServer, DatastoreMessage >::processAll().
|
inlineprivate |
Read existing shares to recover MemoryChannels after restart.
Definition at line 359 of file ChannelServer.h.
Referenced by ChannelServer< DatastoreServer, DatastoreMessage >::ChannelServer().
|
inlineprotected |
Keep retrying requests until all served.
Definition at line 251 of file ChannelServer.h.
Referenced by ChannelServer< DatastoreServer, DatastoreMessage >::processAll(), and ChannelServer< DatastoreServer, DatastoreMessage >::timeout().
|
inlineprotectedvirtual |
Retry any pending requests.
Reimplemented in FileSystemServer, and NetworkServer.
Definition at line 234 of file ChannelServer.h.
|
inline |
Enters an infinite loop, serving incoming requests.
Definition at line 161 of file ChannelServer.h.
Referenced by main().
|
inline |
Set a sleep timeout.
msec | Milliseconds to sleep (approximately) |
Definition at line 179 of file ChannelServer.h.
Referenced by ARP::lookupAddress().
|
inlineprivate |
Let this process sleep until more events are raised.
Definition at line 277 of file ChannelServer.h.
Referenced by ChannelServer< DatastoreServer, DatastoreMessage >::run().
|
inlineprotectedvirtual |
Called when sleep timeout is reached.
Definition at line 222 of file ChannelServer.h.
Referenced by ChannelServer< DatastoreServer, DatastoreMessage >::sleepUntilWakeup().
|
protected |
Client for sending replies.
Definition at line 529 of file ChannelServer.h.
Referenced by ChannelServer< DatastoreServer, DatastoreMessage >::readChannels().
|
protected |
System timer expiration value.
Definition at line 550 of file ChannelServer.h.
Referenced by ChannelServer< DatastoreServer, DatastoreMessage >::ChannelServer(), ChannelServer< DatastoreServer, DatastoreMessage >::setTimeout(), and ChannelServer< DatastoreServer, DatastoreMessage >::sleepUntilWakeup().
|
protected |
Server object instance.
Definition at line 526 of file ChannelServer.h.
Referenced by ChannelServer< DatastoreServer, DatastoreMessage >::readChannels(), ChannelServer< DatastoreServer, DatastoreMessage >::readKernelEvents(), and ChannelServer< DatastoreServer, DatastoreMessage >::retryAllRequests().
|
protected |
IPC handler functions.
Definition at line 538 of file ChannelServer.h.
Referenced by ChannelServer< DatastoreServer, DatastoreMessage >::addIPCHandler(), ChannelServer< DatastoreServer, DatastoreMessage >::readChannels(), and ChannelServer< DatastoreServer, DatastoreMessage >::~ChannelServer().
|
protected |
IRQ handler functions.
Definition at line 541 of file ChannelServer.h.
Referenced by ChannelServer< DatastoreServer, DatastoreMessage >::addIRQHandler(), ChannelServer< DatastoreServer, DatastoreMessage >::readKernelEvents(), and ChannelServer< DatastoreServer, DatastoreMessage >::~ChannelServer().
|
protected |
Kernel event channel.
Definition at line 535 of file ChannelServer.h.
Referenced by ChannelServer< DatastoreServer, DatastoreMessage >::ChannelServer(), and ChannelServer< DatastoreServer, DatastoreMessage >::readKernelEvents().
|
protected |
Contains registered channels.
Definition at line 532 of file ChannelServer.h.
Referenced by ChannelServer< DatastoreServer, DatastoreMessage >::accept(), ChannelServer< DatastoreServer, DatastoreMessage >::readChannels(), and ChannelServer< DatastoreServer, DatastoreMessage >::readKernelEvents().
|
protected |
ProcessID of ourselves.
Definition at line 544 of file ChannelServer.h.
Referenced by ChannelServer< DatastoreServer, DatastoreMessage >::accept(), ChannelServer< DatastoreServer, DatastoreMessage >::ChannelServer(), ChannelServer< DatastoreServer, DatastoreMessage >::readChannels(), ChannelServer< DatastoreServer, DatastoreMessage >::readKernelEvents(), and ChannelServer< DatastoreServer, DatastoreMessage >::recoverChannels().
|
protected |
System timer value.
Definition at line 547 of file ChannelServer.h.
Referenced by ChannelServer< DatastoreServer, DatastoreMessage >::setTimeout(), and ChannelServer< DatastoreServer, DatastoreMessage >::sleepUntilWakeup().
|
staticprivate |
Maximum number of IPC/IRQ handlers.
Definition at line 84 of file ChannelServer.h.