1#ifndef BITSIM_DISTRIBUTED_TRANSPORT_H
2#define BITSIM_DISTRIBUTED_TRANSPORT_H
6#include <boost/noncopyable.hpp>
41 virtual void publish(
const std::string &bytes) = 0;
46 virtual std::optional<std::string>
receive(std::chrono::milliseconds timeout) = 0;
62 std::unique_ptr<Transport>
connect();
66 void publish_(
const Endpoint *from,
const std::string &bytes);
69 std::vector<Endpoint *> endpoints_;
91 LossyTransport(std::unique_ptr<Transport> inner,
const Config &config);
93 void publish(
const std::string &bytes)
override { inner_->publish(bytes); }
95 std::optional<std::string>
receive(std::chrono::milliseconds timeout)
override;
100 using clock_type = std::chrono::steady_clock;
103 clock_type::time_point release;
106 bool operator>(
const Held &other)
const
108 return release > other.release || (release == other.release && order > other.order);
112 std::unique_ptr<Transport> inner_;
115 std::priority_queue<Held, std::vector<Held>, std::greater<Held>> held_;
The basic types of bitsim. Code outside this file names Eigen's matrix and vector types only through ...
Definition transport.cpp:12
Participants that are threads of one process, joined by queues.
Definition transport.h:57
std::unique_ptr< Transport > connect()
A transport for a new participant.
Definition transport.cpp:37
void publish(const std::string &bytes) override
Send bytes to every other participant.
Definition transport.h:93
uint_t n_lost() const noexcept
Definition transport.h:97
LossyTransport(std::unique_ptr< Transport > inner, const Config &config)
Definition transport.cpp:57
std::optional< std::string > receive(std::chrono::milliseconds timeout) override
The next message from another participant, waiting at most timeout.
Definition transport.cpp:63
How the participants of a distributed simulation reach each other: everything one publishes,...
Definition transport.h:34
virtual void publish(const std::string &bytes)=0
Send bytes to every other participant.
virtual std::optional< std::string > receive(std::chrono::milliseconds timeout)=0
The next message from another participant, waiting at most timeout.
virtual ~Transport()=default
Definition chrono_ghosts.cpp:12
Definition dc_motor_backend_base.h:9
std::size_t uint_t
uint_t
Definition bitsim_types.h:40
double real_t
real_t
Definition bitsim_types.h:20
Definition transport.h:84
uint_t seed
Definition transport.h:88
real_t latency
[s]
Definition transport.h:85
real_t jitter
[s], the standard deviation of a delay added to latency
Definition transport.h:86
real_t loss
the probability that a message is lost
Definition transport.h:87