FreeNOS
|
Client for using Channels on the local processor. More...
#include <ChannelClient.h>
Data Structures | |
struct | Request |
Holds an outgoing request. More... | |
Public Types | |
enum | Result { Success, InvalidArgument, InvalidSize, IOError, OutOfMemory, NotFound } |
Result codes. More... | |
Public Member Functions | |
ChannelClient () | |
Constructor. More... | |
virtual | ~ChannelClient () |
Destructor. More... | |
ChannelRegistry & | getRegistry () |
Get channel registry. More... | |
virtual Result | initialize () |
Initialize the ChannelClient. More... | |
virtual Result | connect (const ProcessID pid, const Size msgSize) |
Connect to a process. More... | |
virtual Result | receiveAny (void *buffer, const Size msgSize, ProcessID *pid) |
Try to receive message from any channel. More... | |
virtual Result | sendRequest (const ProcessID pid, void *buffer, const Size msgSize, CallbackFunction *callback) |
Send asynchronous request message. More... | |
virtual Result | processResponse (const ProcessID pid, ChannelMessage *msg) |
Process a response message. More... | |
virtual Result | syncReceiveFrom (void *buffer, const Size msgSize, const ProcessID pid) |
Synchronous receive from one process. More... | |
virtual Result | syncSendTo (const void *buffer, const Size msgSize, const ProcessID pid) |
Synchronous send to one process. More... | |
virtual Result | syncSendReceive (void *buffer, const Size msgSize, const ProcessID pid) |
Synchronous send and receive to/from one process. More... | |
Private Types | |
typedef struct ChannelClient::Request | Request |
Holds an outgoing request. More... | |
Private Member Functions | |
Channel * | findConsumer (const ProcessID pid, const Size msgSize) |
Get consumer for a process. More... | |
Channel * | findProducer (const ProcessID pid, const Size msgSize) |
Get producer for a process. More... | |
Private Attributes | |
ChannelRegistry | m_registry |
Contains registered channels. More... | |
Index< Request, MaximumRequests > | m_requests |
Contains ongoing requests. More... | |
const ProcessID | m_pid |
Current Process ID. More... | |
Static Private Attributes | |
static const Size | MaximumRequests = 32u |
Maximum number of concurrent outgoing requests. More... | |
static const Size | MaxConnectRetries = 16u |
Maximum number of retries for establishing new connection. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from StrictSingleton< ChannelClient > | |
static ChannelClient * | instance () |
Retrieve the instance. More... | |
Client for using Channels on the local processor.
Definition at line 44 of file ChannelClient.h.
|
private |
Holds an outgoing request.
Result codes.
Enumerator | |
---|---|
Success | |
InvalidArgument | |
InvalidSize | |
IOError | |
OutOfMemory | |
NotFound |
Definition at line 81 of file ChannelClient.h.
ChannelClient::ChannelClient | ( | ) |
Constructor.
Definition at line 24 of file ChannelClient.cpp.
|
virtual |
Destructor.
Definition at line 30 of file ChannelClient.cpp.
|
virtual |
Connect to a process.
This function creates a producer and consumer Channel to the given process and registers it with the ChannelRegistry.
pid | ProcessID for the process to connect to. |
msgSize | Message size to use. |
Definition at line 44 of file ChannelClient.cpp.
References Memory::Range::access, Channel::Consumer, ProcessShares::MemoryShare::coreId, SystemInformation::coreId, API::Create, ERROR, IOError, m_pid, m_registry, MaxConnectRetries, OutOfMemory, PAGESIZE, Memory::Range::phys, ProcessShares::MemoryShare::pid, ProcessCtl(), Channel::Producer, ProcessShares::MemoryShare::range, Memory::Readable, ChannelRegistry::registerConsumer(), ChannelRegistry::registerProducer(), Schedule, SELF, MemoryChannel::setVirtual(), Memory::Range::size, Channel::Success, API::Success, Success, ProcessShares::MemoryShare::tagId, API::TemporaryUnavailable, Memory::User, Memory::Range::virt, VMShare(), Wakeup, and Memory::Writable.
Referenced by findConsumer(), and findProducer().
Get consumer for a process.
pid | ProcessID of the process |
msgSize | Message size to use. |
Definition at line 243 of file ChannelClient.cpp.
References connect(), ERROR, ChannelRegistry::getConsumer(), m_registry, Success, and ZERO.
Referenced by syncReceiveFrom().
Get producer for a process.
pid | ProcessID of the process |
msgSize | Message size to use. |
Definition at line 260 of file ChannelClient.cpp.
References connect(), ERROR, ChannelRegistry::getProducer(), m_registry, Success, and ZERO.
Referenced by sendRequest(), and syncSendTo().
ChannelRegistry & ChannelClient::getRegistry | ( | ) |
Get channel registry.
Definition at line 34 of file ChannelClient.cpp.
References m_registry.
|
virtual |
Initialize the ChannelClient.
Definition at line 39 of file ChannelClient.cpp.
References Success.
|
virtual |
Process a response message.
pid | ProcessID from which we receive the message |
msg | Message which is received |
Definition at line 220 of file ChannelClient.cpp.
References ChannelClient::Request::active, ChannelClient::Request::callback, CallbackFunction::execute(), ChannelMessage::identifier, m_requests, ChannelClient::Request::message, NotFound, ChannelClient::Request::pid, and Success.
Referenced by ChannelServer< DatastoreServer, DatastoreMessage >::readChannels().
|
virtual |
Try to receive message from any channel.
buffer | Message buffer for output |
msgSize | Message size to use. |
pid | ProcessID for output |
Definition at line 140 of file ChannelClient.cpp.
References assert, ChannelRegistry::getConsumers(), HashIterator< K, V >::hasCurrent(), m_registry, NotFound, Channel::Success, and Success.
|
virtual |
Send asynchronous request message.
The client assigns an internal request identifier for the message and ensures that the callback will be called when a response messages is received.
pid | ProcessID to send the message to |
buffer | Points to message to send |
msgSize | Message size to use. |
callback | Called when response message is received |
Definition at line 156 of file ChannelClient.cpp.
References ChannelClient::Request::active, assert, ChannelClient::Request::callback, MemoryBlock::copy(), DEBUG, ERROR, findProducer(), Channel::getMessageSize(), ChannelMessage::identifier, IOError, m_requests, ChannelClient::Request::message, NotFound, NULL, OutOfMemory, ChannelClient::Request::pid, ProcessCtl(), ChannelMessage::Request, Channel::Success, Success, ChannelMessage::type, Wakeup, and Channel::write().
|
virtual |
Synchronous receive from one process.
buffer | Message buffer for output |
msgSize | Message size to use. |
pid | ProcessID for the channel |
Definition at line 277 of file ChannelClient.cpp.
References EnterSleep, ERROR, findConsumer(), NotFound, ProcessCtl(), Channel::read(), SELF, Channel::Success, and Success.
Referenced by syncSendReceive().
|
virtual |
Synchronous send and receive to/from one process.
buffer | Message buffer to send/receive |
msgSize | Message size to use. |
pid | ProcessID for the channel |
Definition at line 322 of file ChannelClient.cpp.
References ERROR, Success, syncReceiveFrom(), and syncSendTo().
Referenced by FileSystemClient::request().
|
virtual |
Synchronous send to one process.
buffer | Message buffer to send |
msgSize | Message size to use. |
pid | ProcessID for the channel |
Definition at line 292 of file ChannelClient.cpp.
References Channel::ChannelFull, ERROR, findProducer(), IOError, NotFound, ProcessCtl(), Schedule, SELF, Channel::Success, Success, Wakeup, and Channel::write().
Referenced by CoreServer::createProcess(), and syncSendReceive().
|
private |
|
private |
Contains registered channels.
Definition at line 229 of file ChannelClient.h.
Referenced by connect(), findConsumer(), findProducer(), getRegistry(), and receiveAny().
|
private |
Contains ongoing requests.
Definition at line 232 of file ChannelClient.h.
Referenced by processResponse(), and sendRequest().
|
staticprivate |
Maximum number of retries for establishing new connection.
Definition at line 52 of file ChannelClient.h.
Referenced by connect().
|
staticprivate |
Maximum number of concurrent outgoing requests.
Definition at line 49 of file ChannelClient.h.