|
|
@@ -3,6 +3,7 @@
|
|
|
#include "utility/bit_operations.hpp"
|
|
|
#include "utility/coro_signal.hpp"
|
|
|
#include "utility/statistic_timer.hpp"
|
|
|
+#include "utility/tiny_signal.hpp"
|
|
|
|
|
|
#include <boost/asio/co_spawn.hpp>
|
|
|
#include <boost/asio/detached.hpp>
|
|
|
@@ -10,7 +11,6 @@
|
|
|
#include <boost/asio/high_resolution_timer.hpp>
|
|
|
#include <boost/asio/this_coro.hpp>
|
|
|
#include <boost/asio/use_awaitable.hpp>
|
|
|
-#include <boost/intrusive/list.hpp>
|
|
|
|
|
|
#include <fmt/format.h>
|
|
|
|
|
|
@@ -30,26 +30,25 @@ namespace sophiar {
|
|
|
template<typename FreqTag>
|
|
|
struct datanode_base<FreqTag>::impl {
|
|
|
|
|
|
- datanode_base *q_this = nullptr;
|
|
|
+ using state_type = typename tristate_obj<FreqTag>::state_type;
|
|
|
+ using connection_signal_type = tiny_signal<typename data_packet::pointer>;
|
|
|
|
|
|
- using connection_hook = boost::intrusive::list_base_hook<
|
|
|
- boost::intrusive::link_mode<
|
|
|
- boost::intrusive::auto_unlink> >;
|
|
|
- struct connection_node_type : public connection_hook {
|
|
|
- datanode_base *datanode;
|
|
|
+ struct connection_node_type : public connection_signal_type::listener_type {
|
|
|
+ impl *p_this;
|
|
|
uint8_t channel_index;
|
|
|
- };
|
|
|
|
|
|
- using connection_list_type = boost::intrusive::list<
|
|
|
- connection_node_type, boost::intrusive::constant_time_size<false> >;
|
|
|
+ void on_signal_received(typename data_packet::pointer packet) override {
|
|
|
+ p_this->update_input_data(channel_index, packet);
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
- using state_type = typename tristate_obj<FreqTag>::state_type;
|
|
|
+ datanode_base *q_this = nullptr;
|
|
|
|
|
|
typename data_packet::pointer input_data[MAX_CHANNEL_CNT];
|
|
|
typename data_packet::pointer output_data[MAX_CHANNEL_CNT];
|
|
|
|
|
|
connection_node_type channel_input_nodes[MAX_CHANNEL_CNT];
|
|
|
- connection_list_type channel_output_list[MAX_CHANNEL_CNT];
|
|
|
+ connection_signal_type channel_output_list[MAX_CHANNEL_CNT];
|
|
|
channel_mask_type input_update_mask = 0;
|
|
|
channel_mask_type output_updated_mask = 0;
|
|
|
|
|
|
@@ -77,7 +76,12 @@ namespace sophiar {
|
|
|
impl()
|
|
|
: trigger_timer(datanode_base::get_context()),
|
|
|
exec_cancel_signal(datanode_base::get_context()),
|
|
|
- run_finished_signal(datanode_base::get_context()) {}
|
|
|
+ run_finished_signal(datanode_base::get_context()) {
|
|
|
+ for (uint8_t i = 0; i < MAX_CHANNEL_CNT; ++i) {
|
|
|
+ channel_input_nodes[i].p_this = this;
|
|
|
+ channel_input_nodes[i].channel_index = i;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
bool check_is_running() const {
|
|
|
return q_this->get_state() == state_type::RUNNING;
|
|
|
@@ -90,9 +94,7 @@ namespace sophiar {
|
|
|
void commit_output() {
|
|
|
for (uint8_t i = 0; i < MAX_CHANNEL_CNT; ++i) {
|
|
|
if (test_bit(output_updated_mask, i)) {
|
|
|
- for (const auto &node: channel_output_list[i]) {
|
|
|
- node.datanode->update_input_data(node.channel_index, output_data[i]);
|
|
|
- }
|
|
|
+ channel_output_list[i].emit_signal(output_data[i]);
|
|
|
}
|
|
|
}
|
|
|
output_updated_mask = 0;
|
|
|
@@ -236,10 +238,6 @@ namespace sophiar {
|
|
|
datanode_base<FreqTag>::datanode_base()
|
|
|
: pimpl(std::make_unique<impl>()) {
|
|
|
pimpl->q_this = this;
|
|
|
- for (uint8_t i = 0; i < MAX_CHANNEL_CNT; ++i) {
|
|
|
- pimpl->channel_input_nodes[i].datanode = this;
|
|
|
- pimpl->channel_input_nodes[i].channel_index = i;
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
template<typename FreqTag>
|
|
|
@@ -308,10 +306,7 @@ namespace sophiar {
|
|
|
assert(sender_channel_index < MAX_CHANNEL_CNT);
|
|
|
assert(receiver_channel_index < MAX_CHANNEL_CNT);
|
|
|
auto &receiver_channel_node = receiver.pimpl->channel_input_nodes[receiver_channel_index];
|
|
|
- if (receiver_channel_node.is_linked()) {
|
|
|
- receiver_channel_node.unlink();
|
|
|
- }
|
|
|
- sender.pimpl->channel_output_list[sender_channel_index].push_back(receiver_channel_node);
|
|
|
+ sender.pimpl->channel_output_list[sender_channel_index].add_listener(receiver_channel_node);
|
|
|
}
|
|
|
|
|
|
template<typename FreqTag>
|