41 virtual void connect(std::optional<unsigned> bufferSize = std::nullopt) {
53 virtual void connectImpl(std::optional<unsigned> bufferSize) {}
88 std::optional<unsigned> bufferSize = std::nullopt);
100 connect(std::optional<unsigned> bufferSize = std::nullopt)
override;
103 virtual std::future<MessageData>
readAsync();
108 std::future<MessageData> f =
readAsync();
110 outData = std::move(f.get());
152 return bundleDir == BundleType::Direction::To;
176 template <
typename T>
178 return const_cast<T *
>(
dynamic_cast<const T *
>(
this));
Services provide connections to 'bundles' – collections of named, unidirectional communication channe...
virtual ~BundlePort()=default
std::map< std::string, ChannelPort & > channels
ReadChannelPort & getRawRead(const std::string &name) const
WriteChannelPort & getRawWrite(const std::string &name) const
Get access to the raw byte streams of a channel.
const std::map< std::string, ChannelPort & > & getChannels() const
T * getAs() const
Cast this Bundle port to a subclass which is actually useful.
static bool isWrite(BundleType::Direction bundleDir)
Compute the direction of a channel given the bundle direction and the bundle port's direction.
BundlePort(AppID id, std::map< std::string, ChannelPort & > channels)
Construct a port.
AppID getID() const
Get the ID of the port.
Unidirectional channels are the basic communication primitive between the host and accelerator.
virtual void disconnect()
ChannelPort(const Type *type)
virtual void connect(std::optional< unsigned > bufferSize=std::nullopt)
Set up a connection to the accelerator.
virtual void connectImpl(std::optional< unsigned > bufferSize)
Called by all connect methods to let backends initiate the underlying connections.
const Type * getType() const
A logical chunk of data representing serialized data.
A ChannelPort which reads data from the accelerator.
virtual std::future< MessageData > readAsync()
Asynchronous read.
std::mutex pollingM
Mutex to protect the two queues used for polling.
virtual void connect(std::function< bool(MessageData)> callback, std::optional< unsigned > bufferSize=std::nullopt)
std::function< bool(MessageData)> callback
Backends call this callback when new data is available.
Mode
Indicates the current mode of the channel.
std::queue< MessageData > dataQueue
Store incoming data here if there are no outstanding promises to be fulfilled.
static constexpr uint64_t DefaultMaxDataQueueMsgs
Default max data queue size set at connect time.
std::queue< std::promise< MessageData > > promiseQueue
Promises to be fulfilled when data is available.
void setMaxDataQueueMsgs(uint64_t maxMsgs)
Set maximum number of messages to store in the dataQueue.
uint64_t maxDataQueueMsgs
Maximum number of messages to store in dataQueue. 0 means no limit.
virtual void disconnect() override
virtual void read(MessageData &outData)
Specify a buffer to read into.
ReadChannelPort(const Type *type)
Root class of the ESI type system.
A ChannelPort which sends data to the accelerator.
virtual void write(const MessageData &)=0
A very basic write API. Will likely change for performance reasons.