eRPC API Reference  Rev. 1.7.2
NXP Semiconductors
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 
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 
71  virtual erpc_status_t receive(MessageBuffer *message);
72 
80  client_token_t prepareClientReceive(RequestContext &request);
81 
88  erpc_status_t clientReceive(client_token_t token);
89 
91  virtual erpc_status_t send(MessageBuffer *message);
92 
98  virtual void setCrc16(Crc16 *crcImpl);
99 
100 protected:
103 
108  {
111  bool m_isValid;
117  PendingClientInfo(void);
118 
122  ~PendingClientInfo(void);
123  };
124 
128 
135 
142 
148  void freeClientList(PendingClientInfo *list);
149 };
150 
151 } // namespace erpc
152 
155 #endif // defined(__embedded_rpc__transport_arbitrator__)
156 // EOF
Abstract interface for transport layer.
Definition: erpc_transport.h:35
int32_t erpc_status_t
Type used for all status and error return values.
Definition: erpc_common.h:86
Interposer to share transport between client and server.
Definition: erpc_transport_arbitrator.h:40
~PendingClientInfo(void)
Destructor.
Definition: erpc_transport_arbitrator.cpp:223
erpc_status_t clientReceive(client_token_t token)
Receive method for the client.
Definition: erpc_transport_arbitrator.cpp:127
Abstract serialization encoder/decoder interface.
Definition: erpc_codec.h:50
client_token_t prepareClientReceive(RequestContext &request)
Add a client request to the client list.
Definition: erpc_transport_arbitrator.cpp:115
virtual erpc_status_t receive(MessageBuffer *message)
Receive method for the server.
Definition: erpc_transport_arbitrator.cpp:45
PendingClientInfo * addPendingClient(void)
This function adds pending client.
Definition: erpc_transport_arbitrator.cpp:142
Request info for a client trying to receive a response.
Definition: erpc_transport_arbitrator.h:107
PendingClientInfo(void)
Constructor.
Definition: erpc_transport_arbitrator.cpp:215
bool m_isValid
Definition: erpc_transport_arbitrator.h:111
Transport * m_sharedTransport
Transport being shared through this arbitrator.
Definition: erpc_transport_arbitrator.h:101
void freeClientList(PendingClientInfo *list)
This function removes pending client list.
Definition: erpc_transport_arbitrator.cpp:204
PendingClientInfo * m_clientFreeList
Unused client receive info structs.
Definition: erpc_transport_arbitrator.h:126
Represents a memory buffer containing a message.
Definition: erpc_message_buffer.h:36
Definition: erpc_arbitrated_client_manager.h:25
PendingClientInfo * m_next
Definition: erpc_transport_arbitrator.h:112
virtual void setCrc16(Crc16 *crcImpl)
This functions sets the CRC-16 implementation.
Definition: erpc_transport_arbitrator.cpp:38
void removePendingClient(PendingClientInfo *info)
This function removes pending client.
Definition: erpc_transport_arbitrator.cpp:172
virtual ~TransportArbitrator(void)
Destructor.
Definition: erpc_transport_arbitrator.cpp:31
Class for compute crc16.
Definition: erpc_crc16.h:29
RequestContext * m_request
Definition: erpc_transport_arbitrator.h:109
void setCodec(Codec *codec)
This function set codec.
Definition: erpc_transport_arbitrator.h:68
virtual erpc_status_t send(MessageBuffer *message)
Shared client/server send method.
Definition: erpc_transport_arbitrator.cpp:109
PendingClientInfo * m_clientList
Active client receive requests.
Definition: erpc_transport_arbitrator.h:125
Codec * m_codec
Codec used to read incoming message headers.
Definition: erpc_transport_arbitrator.h:102
Mutex m_clientListMutex
Mutex guarding the client active and free lists.
Definition: erpc_transport_arbitrator.h:127
void setSharedTransport(Transport *shared)
This function set shared client/server transport.
Definition: erpc_transport_arbitrator.h:61
Semaphore m_sem
Definition: erpc_transport_arbitrator.h:110
TransportArbitrator(void)
Constructor.
Definition: erpc_transport_arbitrator.cpp:21
uintptr_t client_token_t
Represents a single client's receive request.
Definition: erpc_transport_arbitrator.h:44
Mutex.
Definition: erpc_threading.h:259
Simple semaphore class.
Definition: erpc_threading.h:359
Encapsulates all information about a request.
Definition: erpc_client_manager.h:219