fabric-bridge: thread-safe startup, detailed Fabrics API logging

This commit is contained in:
Johanness
2026-06-14 16:54:37 +03:00
parent 17a8b23d03
commit a6ac2bf1a1
2 changed files with 17 additions and 7 deletions
+16 -7
View File
@@ -44,20 +44,30 @@ void FabricBridgeNode::configure(const nlohmann::json& params) {
if (params.contains("target_info")) {
target_info_str_ = params["target_info"].get<std::string>();
if (mode_ == FabricMode::Initiator && reader_.has_value() && !target_info_str_.empty()) {
start_requested_.store(true);
spdlog::info("Fabric-bridge: target_info set, signaling startup");
}
}
}
void FabricBridgeNode::on_add_writer(const std::string& port_id, mxlFlowWriter writer) {
if (port_id == "video_out") {
writer_ = writer;
spdlog::info("Fabric-bridge: writer added (target mode)");
start_requested_.store(true);
spdlog::info("Fabric-bridge: writer added (target mode), signaling startup");
}
}
void FabricBridgeNode::on_add_reader(const std::string& port_id, mxlFlowReader reader) {
if (port_id == "video_in") {
reader_ = reader;
spdlog::info("Fabric-bridge: reader added (initiator mode)");
if (mode_ == FabricMode::Initiator && !target_info_str_.empty()) {
start_requested_.store(true);
spdlog::info("Fabric-bridge: reader added (initiator mode), signaling startup");
} else {
spdlog::info("Fabric-bridge: reader added (initiator mode), waiting for target_info");
}
}
}
@@ -76,12 +86,11 @@ void FabricBridgeNode::on_remove_reader(const std::string& port_id) {
}
void FabricBridgeNode::process() {
if (!worker_thread_.has_value()) {
if (mode_ == FabricMode::Initiator && reader_.has_value() && !target_info_str_.empty()) {
running_ = true;
if (!worker_thread_.has_value() && start_requested_.load()) {
running_ = true;
if (mode_ == FabricMode::Initiator) {
worker_thread_ = std::thread(&FabricBridgeNode::run_initiator, this);
} else if (mode_ == FabricMode::Target && writer_.has_value()) {
running_ = true;
} else {
worker_thread_ = std::thread(&FabricBridgeNode::run_target, this);
}
}
@@ -57,6 +57,7 @@ private:
std::optional<std::thread> worker_thread_;
std::atomic<bool> running_{false};
std::atomic<bool> start_requested_{false};
};
} // namespace dmf_node