| eRPC API Reference Rev. 1.8.1 NXP Semiconductors

- Main Page
- API Reference
- Classes
- Files

- File List
- File Members

erpc_transport_arbitrator.h
Go to the documentation of this file.
1 /*
2 * Copyright (c) 2016, Freescale Semiconductor, Inc.
3 * Copyright 2016-2017 NXP
4 * All rights reserved.
5 *
6 *
7 * SPDX-License-Identifier: BSD-3-Clause
8 */
9 #if !defined(__embedded_rpc__transport_arbitrator__)
10 #define __embedded_rpc__transport_arbitrator__
11
12 #include "erpc_client_manager.h"
13 #include "erpc_codec.h"
14 #include "erpc_threading.h"
15 #include "erpc_transport.h"
16
23 // Classes
26
27 namespace erpc {
28 class Codec;
29
40 class TransportArbitrator : public Transport
41 {
42 public:
44 typedef uintptr_t client_token_t;
45
49 TransportArbitrator(void);
50
54 virtual ~TransportArbitrator(void);
55
61 void setSharedTransport(Transport *shared) { m_sharedTransport = shared; }
62
68 void setCodec(Codec *codec) { m_codec = codec; }
69
79 virtual erpc_status_t receive(MessageBuffer *message) override;
80
92 client_token_t prepareClientReceive(RequestContext &request);
93
104 erpc_status_t clientReceive(client_token_t token);
105
115 virtual erpc_status_t send(MessageBuffer *message) override;
116
122 virtual void setCrc16(Crc16 *crcImpl) override;
123
124 protected:
125 Transport *m_sharedTransport;
126 Codec *m_codec;
127
131 struct PendingClientInfo
132 {
133 RequestContext *m_request;
134 Semaphore m_sem;
135 bool m_isValid;
136 PendingClientInfo *m_next;
141 PendingClientInfo(void);
142
146 ~PendingClientInfo(void);
147 };
148
149 PendingClientInfo *m_clientList;
150 PendingClientInfo *m_clientFreeList;
151 Mutex m_clientListMutex;
152
158 PendingClientInfo *addPendingClient(void);
159
165 void removePendingClient(PendingClientInfo *info);
166
172 void freeClientList(PendingClientInfo *list);
173 };
174
175 } // namespace erpc
176
179 #endif // defined(__embedded_rpc__transport_arbitrator__)
180 // EOF
erpc::Transport
Abstract interface for transport layer.
Definition: erpc_transport.h:36
erpc::TransportArbitrator
Interposer to share transport between client and server.
Definition: erpc_transport_arbitrator.h:40
erpc_client_manager.h
erpc::TransportArbitrator::PendingClientInfo::~PendingClientInfo
~PendingClientInfo(void)
Destructor.
Definition: erpc_transport_arbitrator.cpp:249
erpc_status_t
enum _erpc_status erpc_status_t
Type used for all status and error return values.
Definition: erpc_common.h:87
erpc::TransportArbitrator::clientReceive
erpc_status_t clientReceive(client_token_t token)
Receive method for the client.
Definition: erpc_transport_arbitrator.cpp:150
erpc::Codec
Abstract serialization encoder/decoder interface.
Definition: erpc_codec.h:53
erpc::TransportArbitrator::prepareClientReceive
client_token_t prepareClientReceive(RequestContext &request)
Add a client request to the client list.
Definition: erpc_transport_arbitrator.cpp:139
erpc::TransportArbitrator::addPendingClient
PendingClientInfo * addPendingClient(void)
This function adds pending client.
Definition: erpc_transport_arbitrator.cpp:165
erpc::TransportArbitrator::PendingClientInfo
Request info for a client trying to receive a response.
Definition: erpc_transport_arbitrator.h:131
erpc::TransportArbitrator::PendingClientInfo::PendingClientInfo
PendingClientInfo(void)
Constructor.
Definition: erpc_transport_arbitrator.cpp:241
erpc_codec.h
erpc_transport.h
erpc::TransportArbitrator::PendingClientInfo::m_isValid
bool m_isValid
Definition: erpc_transport_arbitrator.h:135
erpc::TransportArbitrator::m_sharedTransport
Transport * m_sharedTransport
Transport being shared through this arbitrator.
Definition: erpc_transport_arbitrator.h:125
erpc::TransportArbitrator::freeClientList
void freeClientList(PendingClientInfo *list)
This function removes pending client list.
Definition: erpc_transport_arbitrator.cpp:228
erpc::TransportArbitrator::m_clientFreeList
PendingClientInfo * m_clientFreeList
Unused client receive info structs.
Definition: erpc_transport_arbitrator.h:150
erpc::MessageBuffer
Represents a memory buffer containing a message.
Definition: erpc_message_buffer.h:37
erpc
Definition: erpc_arbitrated_client_manager.h:25
erpc::TransportArbitrator::PendingClientInfo::m_next
PendingClientInfo * m_next
Definition: erpc_transport_arbitrator.h:136
erpc::TransportArbitrator::removePendingClient
void removePendingClient(PendingClientInfo *info)
This function removes pending client.
Definition: erpc_transport_arbitrator.cpp:195
erpc_threading.h
erpc::TransportArbitrator::~TransportArbitrator
virtual ~TransportArbitrator(void)
Destructor.
Definition: erpc_transport_arbitrator.cpp:38
erpc::Crc16
Class for compute crc16.
Definition: erpc_crc16.h:29
erpc::TransportArbitrator::PendingClientInfo::m_request
RequestContext * m_request
Definition: erpc_transport_arbitrator.h:133
erpc::TransportArbitrator::setCrc16
virtual void setCrc16(Crc16 *crcImpl) override
This functions sets the CRC-16 implementation.
Definition: erpc_transport_arbitrator.cpp:45
erpc::TransportArbitrator::setCodec
void setCodec(Codec *codec)
This function set codec.
Definition: erpc_transport_arbitrator.h:68
erpc::TransportArbitrator::m_clientList
PendingClientInfo * m_clientList
Active client receive requests.
Definition: erpc_transport_arbitrator.h:149
erpc::TransportArbitrator::m_codec
Codec * m_codec
Codec used to read incoming message headers.
Definition: erpc_transport_arbitrator.h:126
erpc::TransportArbitrator::m_clientListMutex
Mutex m_clientListMutex
Mutex guarding the client active and free lists.
Definition: erpc_transport_arbitrator.h:151
erpc::TransportArbitrator::receive
virtual erpc_status_t receive(MessageBuffer *message) override
Prototype for receiving message.
Definition: erpc_transport_arbitrator.cpp:52
erpc::TransportArbitrator::setSharedTransport
void setSharedTransport(Transport *shared)
This function set shared client/server transport.
Definition: erpc_transport_arbitrator.h:61
erpc::TransportArbitrator::PendingClientInfo::m_sem
Semaphore m_sem
Definition: erpc_transport_arbitrator.h:134
erpc::TransportArbitrator::TransportArbitrator
TransportArbitrator(void)
Constructor.
Definition: erpc_transport_arbitrator.cpp:28
erpc::TransportArbitrator::send
virtual erpc_status_t send(MessageBuffer *message) override
Prototype for send message.
Definition: erpc_transport_arbitrator.cpp:133
erpc::TransportArbitrator::client_token_t
uintptr_t client_token_t
Represents a single client&#39;s receive request.
Definition: erpc_transport_arbitrator.h:44
erpc::Mutex
Mutex.
Definition: erpc_threading.h:307
erpc::Semaphore
Simple semaphore class.
Definition: erpc_threading.h:411
erpc::RequestContext
Encapsulates all information about a request.
Definition: erpc_client_manager.h:212