fixed some style issues, added tooling for docs
This commit is contained in:
@@ -18,14 +18,14 @@ void log_error(std::string_view type,
|
||||
std::mutex &error_mutex() noexcept;
|
||||
|
||||
template <class T>
|
||||
inline T&& show(std::string_view name, T&& value) noexcept {
|
||||
inline T&&show(std::string_view name, T&&value) noexcept {
|
||||
std::lock_guard<std::mutex> lock(error_mutex());
|
||||
std::cerr << name << '=' << value << '\n';
|
||||
return std::forward<T>(value);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T&& eval_and_show(std::string_view expr, T&& value) noexcept {
|
||||
inline T&&eval_and_show(std::string_view expr, T&&value) noexcept {
|
||||
std::lock_guard<std::mutex> lock(error_mutex());
|
||||
std::cerr << expr << '=' << value << '\n';
|
||||
return std::forward<T>(value);
|
||||
|
||||
@@ -10,7 +10,7 @@ Host::Host(Simulator *const sim, NodeId id) noexcept
|
||||
Node::set_status(NodeStatus::OK);
|
||||
}
|
||||
|
||||
void Host::attach_nic(NetworkNic* nic) noexcept {
|
||||
void Host::attach_nic(NetworkNic *nic) noexcept {
|
||||
if (_nic && _nic != nic) {
|
||||
log_error("ERROR", "Host::attach_nic called while NIC already attached");
|
||||
}
|
||||
@@ -18,7 +18,7 @@ void Host::attach_nic(NetworkNic* nic) noexcept {
|
||||
_nic = nic;
|
||||
}
|
||||
|
||||
void Host::detach_nic(NetworkNic* nic) noexcept {
|
||||
void Host::detach_nic(NetworkNic *nic) noexcept {
|
||||
if (_nic && _nic != nic) {
|
||||
log_error("ERROR", "Host::detach_nic called with non-matching NIC pointer");
|
||||
return;
|
||||
|
||||
@@ -22,8 +22,8 @@ public:
|
||||
}
|
||||
|
||||
// NIC lifecycle hooks (called by the NIC)
|
||||
void attach_nic(NetworkNic* nic) noexcept;
|
||||
void detach_nic(NetworkNic* nic) noexcept;
|
||||
void attach_nic(NetworkNic *nic) noexcept;
|
||||
void detach_nic(NetworkNic *nic) noexcept;
|
||||
|
||||
// Data-plane completion: a whole flow has arrived.
|
||||
virtual void recv_flow(NodeId src,
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
Bytes flow_size) = 0;
|
||||
|
||||
// Control/telemetry interrupt: ACK/NACK/TRIM_BACK, etc.
|
||||
virtual void recv_frame(const Packet& frame) = 0;
|
||||
virtual void recv_frame(const Packet &frame) = 0;
|
||||
|
||||
virtual void recv_mgmt_msg(std::unique_ptr<struct MgmtMsg> msg) = 0;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ void Node::set_status(NodeStatus s) noexcept {
|
||||
}
|
||||
|
||||
static inline bool schedule_status_ok_after(Simulator *const sim, Time delay_ns,
|
||||
Node* self) {
|
||||
Node *self) {
|
||||
if (!sim) {
|
||||
log_error("ERROR", "Node: simulator instance not found for boot/reboot");
|
||||
return false;
|
||||
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T choose_weighted(const std::vector<std::pair<double, T>>& items) {
|
||||
T choose_weighted(const std::vector<std::pair<double, T>> &items) {
|
||||
return choose_weighted_impl(items.begin(), items.end());
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
namespace dofs {
|
||||
|
||||
bool Simulator::Cmp::operator()(const Item& a, const Item& b) const noexcept {
|
||||
bool Simulator::Cmp::operator()(const Item &a, const Item &b) const noexcept {
|
||||
if (a.when != b.when)
|
||||
return a.when > b.when;
|
||||
|
||||
@@ -40,7 +40,7 @@ bool Simulator::run_next() {
|
||||
|
||||
void Simulator::run_until(Time end_time) {
|
||||
while (!_event_pq.empty()) {
|
||||
const Item& top = _event_pq.top();
|
||||
const Item &top = _event_pq.top();
|
||||
|
||||
if (end_time < top.when)
|
||||
break;
|
||||
@@ -67,7 +67,7 @@ void Simulator::flush_after(Time grace) noexcept {
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::unique_ptr<Simulator>>& Simulator::_registry() {
|
||||
std::vector<std::unique_ptr<Simulator>> &Simulator::_registry() {
|
||||
static std::vector<std::unique_ptr<Simulator>> reg;
|
||||
return reg;
|
||||
}
|
||||
@@ -77,7 +77,7 @@ std::pair<InstanceId, Simulator *> Simulator::create_simulator(InstanceId id) {
|
||||
return {INVALID_INSTANCE_ID, nullptr};
|
||||
}
|
||||
|
||||
auto& reg = _registry();
|
||||
auto ® = _registry();
|
||||
|
||||
if (static_cast<size_t>(id) >= reg.size()) {
|
||||
reg.resize(static_cast<size_t>(id) + 1);
|
||||
@@ -85,7 +85,7 @@ std::pair<InstanceId, Simulator *> Simulator::create_simulator(InstanceId id) {
|
||||
|
||||
if (!reg[static_cast<size_t>(id)]) {
|
||||
auto sim = std::make_unique<Simulator>();
|
||||
Simulator* ptr = sim.get();
|
||||
Simulator *ptr = sim.get();
|
||||
reg[static_cast<size_t>(id)] = std::move(sim);
|
||||
return {id, ptr};
|
||||
}
|
||||
@@ -97,7 +97,7 @@ Simulator * Simulator::get_simulator(InstanceId id) noexcept {
|
||||
if (id == INVALID_INSTANCE_ID)
|
||||
return nullptr;
|
||||
|
||||
auto& reg = _registry();
|
||||
auto ® = _registry();
|
||||
const size_t idx = static_cast<size_t>(id);
|
||||
|
||||
if (idx >= reg.size())
|
||||
@@ -122,8 +122,8 @@ Rng const * Simulator::get_rng() const noexcept {
|
||||
}
|
||||
|
||||
std::pair<LinkId, Link *> Simulator::create_link(
|
||||
NetworkNode* a, PortId a_port,
|
||||
NetworkNode* b, PortId b_port,
|
||||
NetworkNode *a, PortId a_port,
|
||||
NetworkNode *b, PortId b_port,
|
||||
Time latency,
|
||||
double bandwidth_gbps) {
|
||||
|
||||
@@ -143,7 +143,7 @@ std::pair<LinkId, Link *> Simulator::create_link(
|
||||
latency,
|
||||
bandwidth_gbps));
|
||||
|
||||
Link* raw = up.get();
|
||||
Link *raw = up.get();
|
||||
_links.push_back(std::move(up));
|
||||
return {id, raw};
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ private:
|
||||
};
|
||||
|
||||
struct Cmp {
|
||||
bool operator()(const Item& a, const Item& b) const noexcept;
|
||||
bool operator()(const Item &a, const Item &b) const noexcept;
|
||||
};
|
||||
|
||||
std::priority_queue<Item, std::vector<Item>, Cmp> _event_pq;
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
Time now() const noexcept;
|
||||
|
||||
template <class F, class... Args>
|
||||
EventId schedule_at(Time abs_time, F&& f, Args&&... args) {
|
||||
EventId schedule_at(Time abs_time, F&&f, Args&&... args) {
|
||||
if (_locked)
|
||||
return NULL_EVENT;
|
||||
|
||||
@@ -81,7 +81,7 @@ public:
|
||||
}
|
||||
|
||||
template <class F, class... Args>
|
||||
EventId schedule_after(Time delay, F&& f, Args&&... args) {
|
||||
EventId schedule_after(Time delay, F&&f, Args&&... args) {
|
||||
return schedule_at(_now + delay, std::forward<F>(f),
|
||||
std::forward<Args>(args)...);
|
||||
}
|
||||
@@ -91,7 +91,7 @@ public:
|
||||
void run_until(Time end_time);
|
||||
|
||||
// ----- Termination helpers -----
|
||||
// Prevent any future schedule_* calls from enqueuing events.
|
||||
// Prevent any future schedule_ *calls from enqueuing events.
|
||||
void lock() noexcept;
|
||||
bool is_locked() const noexcept {
|
||||
return _locked;
|
||||
@@ -100,21 +100,21 @@ public:
|
||||
void flush_after(Time grace) noexcept;
|
||||
|
||||
// ---------- Object management ----------
|
||||
Rng* create_rng(std::uint64_t seed);
|
||||
Rng* get_rng() noexcept;
|
||||
Rng const* get_rng() const noexcept;
|
||||
Rng *create_rng(std::uint64_t seed);
|
||||
Rng *get_rng() noexcept;
|
||||
Rng const *get_rng() const noexcept;
|
||||
|
||||
std::pair<LinkId, Link *> create_link(NetworkNode* a, PortId a_port,
|
||||
NetworkNode* b, PortId b_port,
|
||||
std::pair<LinkId, Link *> create_link(NetworkNode *a, PortId a_port,
|
||||
NetworkNode *b, PortId b_port,
|
||||
Time latency,
|
||||
double bandwidth_gbps);
|
||||
|
||||
Link* get_link(LinkId id) noexcept;
|
||||
Link const* get_link(LinkId id) const noexcept;
|
||||
Link *get_link(LinkId id) noexcept;
|
||||
Link const *get_link(LinkId id) const noexcept;
|
||||
|
||||
private:
|
||||
template <class F, class... Args>
|
||||
static auto make_callable(F&& f, Args&&... args) {
|
||||
static auto make_callable(F&&f, Args&&... args) {
|
||||
using Fn = std::decay_t<F>;
|
||||
using Tup = std::tuple<std::decay_t<Args>...>;
|
||||
return [fn = Fn(std::forward<F>(f)),
|
||||
@@ -123,7 +123,7 @@ private:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::unique_ptr<Simulator>>& _registry();
|
||||
static std::vector<std::unique_ptr<Simulator>> &_registry();
|
||||
};
|
||||
|
||||
} // namespace dofs
|
||||
|
||||
Reference in New Issue
Block a user