diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-07-26 20:35:31 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-07-26 20:35:31 +0200 |
commit | cc1a4b9493e0e6996e4138f65630b66199ee088a (patch) | |
tree | b5d78383796efc74ea0eae543da4a3530a077218 | |
parent | f706404e6e40043b87ff19e32c8fd11958772e9d (diff) | |
download | gmrf-cc1a4b9493e0e6996e4138f65630b66199ee088a.tar gmrf-cc1a4b9493e0e6996e4138f65630b66199ee088a.zip |
Miscellanous fixes
-rw-r--r-- | mmss/iface.cpp | 6 | ||||
-rw-r--r-- | mmss/mmss.cpp | 4 | ||||
-rw-r--r-- | mmss/mmss.hpp | 8 | ||||
-rw-r--r-- | mmss/queue.hpp | 3 | ||||
-rw-r--r-- | mmss/schedule.cpp | 2 | ||||
-rw-r--r-- | mmss/types.hpp | 3 |
6 files changed, 15 insertions, 11 deletions
diff --git a/mmss/iface.cpp b/mmss/iface.cpp index 602daa2..c011255 100644 --- a/mmss/iface.cpp +++ b/mmss/iface.cpp @@ -31,7 +31,7 @@ namespace MMSS { -void dispatch(std::shared_ptr<packet_t> packet) { +void dispatch(const std::shared_ptr<packet_t> &packet) { auto source = packet->source.lock(); auto dest = packet->dest.lock(); if (!source || !dest) @@ -44,7 +44,7 @@ void dispatch(std::shared_ptr<packet_t> packet) { node->proto->handle_packet(node.get(), node->ctx, dest.get(), &source->address, packet->data.get(), packet->len); } -void add_iface(std::shared_ptr<node_t> node, std::shared_ptr<network_t> net, const std::string &name, const gmrf_addr_t *address) { +void add_iface(const std::shared_ptr<node_t> &node, const std::shared_ptr<network_t> &net, const std::string &name, const gmrf_addr_t *address) { std::shared_ptr<iface_t> iface = iface_t::create(); iface->name = name; @@ -59,7 +59,7 @@ void add_iface(std::shared_ptr<node_t> node, std::shared_ptr<network_t> net, con node->proto->add_iface(node.get(), node->ctx, iface.get()); } -void enqueue(context_t *mmss, std::shared_ptr<iface_t> source, std::shared_ptr<iface_t> dest, const void *data, size_t len) { +void enqueue(context_t *mmss, const std::shared_ptr<iface_t> &source, const std::shared_ptr<iface_t> &dest, const void *data, size_t len) { std::shared_ptr<packet_t> packet = std::make_shared<packet_t>(); packet->sent = mmss->now; diff --git a/mmss/mmss.cpp b/mmss/mmss.cpp index 1d918e4..548425f 100644 --- a/mmss/mmss.cpp +++ b/mmss/mmss.cpp @@ -74,8 +74,8 @@ void main(int argc, char *argv[]) { std::shared_ptr<network_t> net0 = std::make_shared<network_t>(); std::shared_ptr<network_t> net1 = std::make_shared<network_t>(); - *net0 = (network_t){ .mtu = 1500 }; - *net1 = (network_t){ .mtu = 1500 }; + net0->mtu = 1500; + net1->mtu = 1500; std::shared_ptr<node_t> node1 = node_t::create(&mmss, "node1", 1, proto); std::shared_ptr<node_t> node2 = node_t::create(&mmss, "node2", 2, proto); diff --git a/mmss/mmss.hpp b/mmss/mmss.hpp index 4045c40..f131ec9 100644 --- a/mmss/mmss.hpp +++ b/mmss/mmss.hpp @@ -138,13 +138,13 @@ const protocol_t* load_protocol(const char *module); bool read_config(context_t *mmss, config_t *conf, const char *filename); -void add_iface(std::shared_ptr<node_t> node, std::shared_ptr<network_t> net, const std::string &name, const gmrf_addr_t *address); +void add_iface(const std::shared_ptr<node_t> &node, const std::shared_ptr<network_t> &net, const std::string &name, const gmrf_addr_t *address); uint64_t now(const context_t *mmss); -void dispatch(std::shared_ptr<packet_t> packet); -void run_scheduled(std::shared_ptr<scheduled_t> scheduled); -void enqueue(context_t *mmss, std::shared_ptr<iface_t> source, std::shared_ptr<iface_t> dest, const void *data, size_t len); +void dispatch(const std::shared_ptr<packet_t> &packet); +void run_scheduled(const std::shared_ptr<scheduled_t> &scheduled); +void enqueue(context_t *mmss, const std::shared_ptr<iface_t> &source, const std::shared_ptr<iface_t> &dest, const void *data, size_t len); void logf(context_t *mmss, int priority, const char *format, ...); diff --git a/mmss/queue.hpp b/mmss/queue.hpp index 0b79ed8..2cdb2a1 100644 --- a/mmss/queue.hpp +++ b/mmss/queue.hpp @@ -29,6 +29,7 @@ #include "types.hpp" +#include <deque> #include <memory> #include <queue> @@ -48,7 +49,7 @@ template<typename T> class timeout_queue_t { context_t *mmss; - std::priority_queue<element_t> queue; + std::priority_queue<element_t, std::deque<element_t>> queue; public: timeout_queue_t(context_t *mmss0) : mmss(mmss0) {} diff --git a/mmss/schedule.cpp b/mmss/schedule.cpp index 7e6247e..77d766d 100644 --- a/mmss/schedule.cpp +++ b/mmss/schedule.cpp @@ -29,7 +29,7 @@ namespace MMSS { -void run_scheduled(std::shared_ptr<scheduled_t> scheduled) { +void run_scheduled(const std::shared_ptr<scheduled_t> &scheduled) { scheduled->f(scheduled->node.get(), scheduled->node->ctx, scheduled->arg); } diff --git a/mmss/types.hpp b/mmss/types.hpp index 3daa486..4a145ae 100644 --- a/mmss/types.hpp +++ b/mmss/types.hpp @@ -51,6 +51,9 @@ typedef ::mmss_protocol_t protocol_t; typedef ::gmrf_t node_t; typedef ::gmrf_iface_t iface_t; + +uint64_t now(const context_t *mmss); + } #endif /* _GMRF_MMSS_TYPES_HPP_ */ |