eRPC API Reference  Rev. 1.12.0
NXP Semiconductors
erpc::TransportArbitrator Class Reference

Interposer to share transport between client and server. More...

#include <erpc_transport_arbitrator.hpp>

+ Inheritance diagram for erpc::TransportArbitrator:
+ Collaboration diagram for erpc::TransportArbitrator:

Classes

struct  PendingClientInfo
 Request info for a client trying to receive a response. More...
 

Public Types

typedef uintptr_t client_token_t
 Represents a single client's receive request.
 

Public Member Functions

 TransportArbitrator (void)
 Constructor.
 
virtual ~TransportArbitrator (void)
 Destructor.
 
virtual uint8_t reserveHeaderSize (void) override
 Size of data placed in MessageBuffer before serializing eRPC data. More...
 
virtual erpc_status_t receive (MessageBuffer *message) override
 Prototype for receiving message. More...
 
virtual erpc_status_t send (MessageBuffer *message) override
 Prototype for send message. More...
 
virtual bool hasMessage (void) override
 Check if the underlying shared transport has a message. More...
 
virtual void setCrc16 (Crc16 *crcImpl) override
 This functions sets the CRC-16 implementation. More...
 
virtual Crc16getCrc16 (void) override
 This functions gets the CRC-16 object. More...
 
void setSharedTransport (Transport *shared)
 This function set shared client/server transport. More...
 
TransportgetSharedTransport (void)
 This function returns shared client/server transport. More...
 
void setCodec (Codec *codec)
 This function set codec. More...
 
CodecgetCodec (void)
 This function get codec. More...
 
client_token_t prepareClientReceive (RequestContext &request)
 Add a client request to the client list. More...
 
erpc_status_t clientReceive (client_token_t token)
 Receive method for the client. More...
 
- Public Member Functions inherited from erpc::Transport
 Transport (void)
 Constructor.
 
virtual ~Transport (void)
 Transport destructor.
 

Protected Member Functions

PendingClientInfocreatePendingClient (void)
 Create a Pending Client object. More...
 
PendingClientInfoaddPendingClient (void)
 This function adds pending client. More...
 
void removePendingClient (PendingClientInfo *info)
 This function removes pending client. More...
 
void freeClientList (PendingClientInfo *list)
 This function removes pending client list. More...
 

Protected Attributes

Transportm_sharedTransport
 Transport being shared through this arbitrator.
 
Codecm_codec
 Codec used to read incoming message headers.
 
PendingClientInfom_clientList
 Active client receive requests.
 
PendingClientInfom_clientFreeList
 Unused client receive info structs.
 
Mutex m_clientListMutex
 Mutex guarding the client active and free lists.
 

Detailed Description

Interposer to share transport between client and server.

Allocates memory for client receive request info. This memory is never freed. It is put on a free list and is reused for future client receives. The class will allocate as many client receive info structs as the maximum number of simultaneous client receive requests from different threads.

Member Function Documentation

uint8_t TransportArbitrator::reserveHeaderSize ( void  )
overridevirtual

Size of data placed in MessageBuffer before serializing eRPC data.

Returns
uint8_t Amount of bytes, reserved before serialized data.

Reimplemented from erpc::Transport.

erpc_status_t TransportArbitrator::receive ( MessageBuffer message)
overridevirtual

Prototype for receiving message.

Each transport layer need define this function.

Parameters
[out]messageWill return pointer to received message buffer.
Returns
based on receive implementation.

Implements erpc::Transport.

erpc_status_t TransportArbitrator::send ( MessageBuffer message)
overridevirtual

Prototype for send message.

Each transport layer need define this function.

Parameters
[in]messagePass message buffer to send.
Returns
based on send implementation.

Implements erpc::Transport.

bool TransportArbitrator::hasMessage ( void  )
overridevirtual

Check if the underlying shared transport has a message.

Return values
Theunderlying transport is expected to return true when a message is available to process and false otherwise.

Reimplemented from erpc::Transport.

void TransportArbitrator::setCrc16 ( Crc16 crcImpl)
overridevirtual

This functions sets the CRC-16 implementation.

Parameters
[in]crcImplObject containing crc-16 compute function.

Reimplemented from erpc::Transport.

Crc16 * TransportArbitrator::getCrc16 ( void  )
overridevirtual

This functions gets the CRC-16 object.

Returns
Crc16* Pointer to CRC-16 object containing crc-16 compute function.

Reimplemented from erpc::Transport.

void TransportArbitrator::setSharedTransport ( Transport shared)

This function set shared client/server transport.

Parameters
[in]sharedShared client/server transport.
Transport * TransportArbitrator::getSharedTransport ( void  )

This function returns shared client/server transport.

Returns
Transport * Returns shared client/server transport.
void TransportArbitrator::setCodec ( Codec codec)

This function set codec.

Parameters
[in]codecCodec.
Codec * TransportArbitrator::getCodec ( void  )

This function get codec.

Returns
Codec * Pointer to codec used within transport.
TransportArbitrator::client_token_t TransportArbitrator::prepareClientReceive ( RequestContext request)

Add a client request to the client list.

This call is made by the client thread prior to sending the invocation to the server. It ensures that the transport arbitrator has the client's response message buffer ready in case it sees the response before the client even has a chance to call clientReceive().

Parameters
[in]requestReuquest context for receive action.
Returns
A token is returned to the client
erpc_status_t TransportArbitrator::clientReceive ( client_token_t  token)

Receive method for the client.

Blocks until the a reply message is received with the expected sequence number that is associated with token. The client must have called prepareClientReceive() previously.

Parameters
[in]tokenThe token previously returned by prepareClientReceive().
Returns
erpc_status_t Return erpc status of client receive function.
TransportArbitrator::PendingClientInfo * TransportArbitrator::createPendingClient ( void  )
protected

Create a Pending Client object.

Returns
PendingClientInfo* Return created object.
TransportArbitrator::PendingClientInfo * TransportArbitrator::addPendingClient ( void  )
protected

This function adds pending client.

Returns
Pending client information.
void TransportArbitrator::removePendingClient ( PendingClientInfo info)
protected

This function removes pending client.

Parameters
[in]infoPending client info to remove.
void TransportArbitrator::freeClientList ( PendingClientInfo list)
protected

This function removes pending client list.

Parameters
[in]listPending client list to remove.

The documentation for this class was generated from the following files: