Skip to content

API · fair::mq

Deviceclass

#include <Device.h>fairmq/Device.h:55GitHub ↗
Inherited by
fair::mq::BenchmarkSampler, fair::mq::Merger, fair::mq::Multiplier, fair::mq::Proxy, fair::mq::Sink, fair::mq::Splitter

No comment in the header yet.

Functions

template<typename Serializer, typename DataType, typename... Args>
void Serialize(Message& msg, DataType&& data, Args&&... args) const

No comment in the header yet.

template<typename Deserializer, typename DataType, typename... Args>
void Deserialize(Message& msg, DataType&& data, Args&&... args) const

No comment in the header yet.

template<typename M>
std::enable_if_t<is_transferrable<M>::value, int64_t> Send(
    M& m,
    const std::string& channel,
    const int index,
    int sndTimeoutMs
)

Send m on chan at index i

m
reference to MessagePtr/Parts/vector<MessagePtr>
chan
channel name
i
channel index
sndTimeoutMs
send timeout in ms, -1 will wait forever (or until interrupt (e.g. via state change)), 0 will not wait (return immediately if cannot send)
Returns
Number of queued bytes, TransferCode::timeout if timed out, TransferCode::error if there was an error, TransferCode::interrupted if interrupted (e.g. by requested state change)
template<typename M>
std::enable_if_t<is_transferrable<M>::value, int64_t> Receive(
    M& m,
    const std::string& channel,
    const int index,
    int rcvTimeoutMs
)

Receive m on chan at index i

m
reference to MessagePtr/Parts/vector<MessagePtr>
chan
channel name
i
channel index
rcvTimeoutMs
receive timeout in ms, -1 will wait forever (or until interrupt (e.g. via state change), 0 will not wait (return immediately if cannot receive)
Returns
Number of received bytes, TransferCode::timeout if timed out, TransferCode::error if there was an error, TransferCode::interrupted if interrupted (e.g. by requested state change)
template<typename T>
void OnData(
    const std::string& channelName,
    bool(T::*)(MessagePtr&msg, int index) memberFunction
)

No comment in the header yet.

template<typename T>
void OnData(
    const std::string& channelName,
    bool(T::*)(Parts&parts, int index) memberFunction
)

No comment in the header yet.

unsigned long GetNumberOfConnectedPeers(
    const std::string& channelName,
    int index = 0
)

Get numbers of connected peers for the given channel.

name
channel name
index
sub-channel
bool RegisterChannelEndpoint(
    const std::string& channelName,
    uint16_t minNumSubChannels = 1,
    uint16_t maxNumSubChannels = 1
)

No comment in the header yet.

void SetTransport(const std::string& transport)

Sets the default transport for the device

transport
Transport string ("zeromq"/"shmem")
template<typename Rep, typename Period>
bool WaitFor(std::chrono::duration<Rep, Period> const& duration)

Wait for the supplied amount of time or for interruption. If interrupted, returns false, otherwise true.

duration
wait duration
bool ChangeState(const Transition transition)

Request a device state transition.

The state transition may not happen immediately, but when the current state evaluates the pending transition event and terminates. In other words, the device states are scheduled cooperatively.

transition
state transition
Returns
whether the transition was successfully scheduled
bool ChangeState(const std::string& transition)

Request a device state transition.

The state transition may not happen immediately, but when the current state evaluates the pending transition event and terminates. In other words, the device states are scheduled cooperatively.

transition
state transition
Returns
whether the transition was successfully scheduled
void WaitForState(const std::string& state)

waits for the specified state to occur

state
state to wait for
void SubscribeToStateChange(
    const std::string& key,
    std::function<void(const State)> callback
)

Subscribe with a callback to state changes.

The callback is called at the beginning of a new state. The callback is called from the thread the state is running in.

key
id to identify your subscription
callback
callback (called with the new state as the parameter)
void SubscribeToNewTransition(
    const std::string& key,
    std::function<void(const Transition)> callback
)

Subscribe with a callback to incoming state transitions.

key
id to identify your subscription
callback
callback (called with the incoming transition as the parameter) The callback is called when new transition is initiated. The callback is called from the thread that initiates the transition (via ChangeState).
bool NewStatePending() const

Returns true if a new state has been requested, signaling the current handler to stop.

Static functions

Static data members

Data members

Protected functions

Init

virtualprotectedDevice.h:472
virtual void Init()

Additional user initialization (can be overloaded in child classes). Prefer to use InitTask().

Bind

virtualprotectedDevice.h:474
virtual void Bind()

No comment in the header yet.

InitTask

virtualprotectedDevice.h:479
virtual void InitTask()

Task initialization (can be overloaded in child classes)

Run

virtualprotectedDevice.h:482
virtual void Run()

Runs the device (to be overloaded in child classes)

PreRun

virtualprotectedDevice.h:485
virtual void PreRun()

Called in the RUNNING state once before executing the Run()/ConditionalRun() method.

virtual bool ConditionalRun()

Called during RUNNING state repeatedly until it returns false or device state changes.

PostRun

virtualprotectedDevice.h:491
virtual void PostRun()

Called in the RUNNING state once after executing the Run()/ConditionalRun() method.

ResetTask

virtualprotectedDevice.h:494
virtual void ResetTask()

Resets the user task (to be overloaded in child classes)

Reset

virtualprotectedDevice.h:497
virtual void Reset()

Resets the device (can be overloaded in child classes)

Protected data members