CIRCT  19.0.0git
Public Types | Public Member Functions | Private Types | Private Attributes | List of all members
esi::cosim::Endpoint Class Reference

Implements a bi-directional, thread-safe bridge between the RPC server and DPI functions. More...

#include <Endpoint.h>

Collaboration diagram for esi::cosim::Endpoint:
Collaboration graph
[legend]

Public Types

using MessageDataPtr = std::unique_ptr< MessageData >
 Representing messages as shared pointers to vectors may be a performance issue in the future but it is the easiest way to ensure memory correctness. More...
 

Public Member Functions

 Endpoint (std::string fromHostTypeId, std::string toHostTypeId)
 Construct an endpoint which knows and the type IDs in both directions. More...
 
 ~Endpoint ()
 
 Endpoint (const Endpoint &)=delete
 Disallow copying. More...
 
std::string getSendTypeId () const
 
std::string getRecvTypeId () const
 
bool setInUse ()
 These two are used to set and unset the inUse flag, to ensure that an open endpoint is not opened again. More...
 
void returnForUse ()
 
void pushMessageToSim (MessageDataPtr msg)
 Queue message to the simulation. More...
 
bool getMessageToSim (MessageDataPtr &msg)
 Pop from the to-simulator queue. More...
 
void pushMessageToClient (MessageDataPtr msg)
 Queue message to the RPC client. More...
 
bool getMessageToClient (MessageDataPtr &msg)
 Pop from the to-RPC-client queue. More...
 

Private Types

using Lock = std::lock_guard< std::mutex >
 

Private Attributes

const std::string fromHostTypeId
 
const std::string toHostTypeId
 
bool inUse
 
std::mutex m
 This class needs to be thread-safe. More...
 
std::queue< MessageDataPtrtoCosim
 Message queue from RPC client to the simulation. More...
 
std::queue< MessageDataPtrtoClient
 Message queue to RPC client from the simulation. More...
 

Detailed Description

Implements a bi-directional, thread-safe bridge between the RPC server and DPI functions.

Several of the methods below are inline with the declaration to make them candidates for inlining during compilation. This is particularly important on the simulation side since polling happens at each clock and we do not want to slow down the simulation any more than necessary.

Definition at line 35 of file Endpoint.h.

Member Typedef Documentation

◆ Lock

using esi::cosim::Endpoint::Lock = std::lock_guard<std::mutex>
private

Definition at line 96 of file Endpoint.h.

◆ MessageDataPtr

Representing messages as shared pointers to vectors may be a performance issue in the future but it is the easiest way to ensure memory correctness.

Definition at line 40 of file Endpoint.h.

Constructor & Destructor Documentation

◆ Endpoint() [1/2]

Endpoint::Endpoint ( std::string  fromHostTypeId,
std::string  toHostTypeId 
)

Construct an endpoint which knows and the type IDs in both directions.

Definition at line 17 of file Endpoint.cpp.

◆ ~Endpoint()

Endpoint::~Endpoint ( )

Definition at line 20 of file Endpoint.cpp.

◆ Endpoint() [2/2]

esi::cosim::Endpoint::Endpoint ( const Endpoint )
delete

Disallow copying.

There is only ONE endpoint object per logical endpoint so copying is almost always a bug.

Member Function Documentation

◆ getMessageToClient()

bool esi::cosim::Endpoint::getMessageToClient ( MessageDataPtr msg)
inline

Pop from the to-RPC-client queue.

Return true if there was a message in the queue.

Definition at line 82 of file Endpoint.h.

References m, and toClient.

◆ getMessageToSim()

bool esi::cosim::Endpoint::getMessageToSim ( MessageDataPtr msg)
inline

Pop from the to-simulator queue.

Return true if there was a message in the queue.

Definition at line 65 of file Endpoint.h.

References m, and toCosim.

Referenced by sv2cCosimserverEpTryGet().

◆ getRecvTypeId()

std::string esi::cosim::Endpoint::getRecvTypeId ( ) const
inline

Definition at line 50 of file Endpoint.h.

References toHostTypeId.

◆ getSendTypeId()

std::string esi::cosim::Endpoint::getSendTypeId ( ) const
inline

Definition at line 49 of file Endpoint.h.

References fromHostTypeId.

◆ pushMessageToClient()

void esi::cosim::Endpoint::pushMessageToClient ( MessageDataPtr  msg)
inline

Queue message to the RPC client.

Definition at line 75 of file Endpoint.h.

References m, and toClient.

Referenced by sv2cCosimserverEpTryPut().

◆ pushMessageToSim()

void esi::cosim::Endpoint::pushMessageToSim ( MessageDataPtr  msg)
inline

Queue message to the simulation.

Definition at line 58 of file Endpoint.h.

References m, and toCosim.

◆ returnForUse()

void Endpoint::returnForUse ( )

Definition at line 30 of file Endpoint.cpp.

References inUse, and m.

◆ setInUse()

bool Endpoint::setInUse ( )

These two are used to set and unset the inUse flag, to ensure that an open endpoint is not opened again.

Definition at line 22 of file Endpoint.cpp.

References inUse, and m.

Member Data Documentation

◆ fromHostTypeId

const std::string esi::cosim::Endpoint::fromHostTypeId
private

Definition at line 92 of file Endpoint.h.

Referenced by getSendTypeId().

◆ inUse

bool esi::cosim::Endpoint::inUse
private

Definition at line 94 of file Endpoint.h.

Referenced by returnForUse(), and setInUse().

◆ m

std::mutex esi::cosim::Endpoint::m
private

This class needs to be thread-safe.

All of the mutable member variables are protected with this object-wide lock. This may be a performance issue in the future.

Definition at line 101 of file Endpoint.h.

Referenced by getMessageToClient(), getMessageToSim(), pushMessageToClient(), pushMessageToSim(), returnForUse(), and setInUse().

◆ toClient

std::queue<MessageDataPtr> esi::cosim::Endpoint::toClient
private

Message queue to RPC client from the simulation.

Definition at line 105 of file Endpoint.h.

Referenced by getMessageToClient(), and pushMessageToClient().

◆ toCosim

std::queue<MessageDataPtr> esi::cosim::Endpoint::toCosim
private

Message queue from RPC client to the simulation.

Definition at line 103 of file Endpoint.h.

Referenced by getMessageToSim(), and pushMessageToSim().

◆ toHostTypeId

const std::string esi::cosim::Endpoint::toHostTypeId
private

Definition at line 93 of file Endpoint.h.

Referenced by getRecvTypeId().


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