Expand description
Central instance that owns all service entities and can handle incoming event in an event loop
The Node is the central entry point of iceoryx2. It is the owner of all communication
entities and provides additional memory to them to perform reference counting amongst other
things.
It allows also the system to monitor the state of processes and cleanup stale resources of dead processes.
§Create a Node
use iceoryx2::prelude::*;
let node = NodeBuilder::new()
.name(&"my_little_node".try_into()?)
.create::<ipc::Service>()?;
println!("created node {:?}", node);§List all existing Nodes
use iceoryx2::prelude::*;
Node::<ipc::Service>::list(Config::global_config(), |node_state| {
println!("found node {:?}", node_state);
CallbackProgression::Continue
});§Cleanup stale resources of all dead Nodes
use iceoryx2::prelude::*;
Node::<ipc::Service>::list(Config::global_config(), |node_state| {
if let NodeState::<ipc::Service>::Dead(view) = node_state {
println!("cleanup resources of dead node {:?}", view);
if let Err(e) = view.remove_stale_resources() {
println!("failed to cleanup resources due to {:?}", e);
}
}
CallbackProgression::Continue
})?;§Simple Event Loop
use core::time::Duration;
use iceoryx2::prelude::*;
const CYCLE_TIME: Duration = Duration::from_secs(1);
let node = NodeBuilder::new()
.name(&"my_little_node".try_into()?)
.create::<ipc::Service>()?;
while node.wait(CYCLE_TIME).is_ok() {
// your algorithm in here
}§Simple Event Loop With Disabled Signal Handling
This example demonstrates how the Node can be used when system signals
are being handled elsewhere. The builder parameter
NodeBuilder::signal_handling_mode()
can be used to disable signal handling in all Node calls like
Node::wait().
use core::time::Duration;
use iceoryx2::prelude::*;
const CYCLE_TIME: Duration = Duration::from_secs(1);
let node = NodeBuilder::new()
.name(&"my_little_node".try_into()?)
// disable signal handling
.signal_handling_mode(SignalHandlingMode::Disabled)
.create::<ipc::Service>()?;
while node.wait(CYCLE_TIME).is_ok() {
// your algorithm in here
}§Advanced Event Loop
use core::time::Duration;
use iceoryx2::node::NodeWaitFailure;
use iceoryx2::prelude::*;
const CYCLE_TIME: Duration = Duration::from_secs(1);
let node = NodeBuilder::new()
.name(&"my_little_node".try_into()?)
.create::<ipc::Service>()?;
loop {
match node.wait(CYCLE_TIME) {
Ok(()) => {
println!("entered next cycle");
}
Err(NodeWaitFailure::TerminationRequest) => {
println!("User pressed CTRL+c, terminating");
break;
}
Err(NodeWaitFailure::Interrupt) => {
println!("Someone send an interrupt signal ...");
}
}
}Modules§
- node_
name - The name for a node.
Structs§
- Alive
Node View - All the informations of a
Nodethat is alive. - Cleanup
State - Returned by
Node::cleanup_dead_nodes(). Contains the cleanup report of the call and contains the number of dead nodes that were successfully cleaned up and how many could not be cleaned up. This does not have to be an error, for instance when the current process does not have the permission to access the corresponding resources. - Dead
Node View - All the informations and management operations belonging to a dead
Node. - Node
- The
Nodeis the entry point to the whole iceoryx2 infrastructure and owns all entities. - Node
Builder - Creates a
Node. - Node
Details - Optional detailed informations that a
Nodecan have. They can only be obtained when the process has sufficient access permissions. - NodeId
- The system-wide unique id of a
Node
Enums§
- Node
Cleanup Failure - Failures of
DeadNodeView::remove_stale_resources()that occur when the stale resources of a deadNodeare removed. - Node
Creation Failure - The failures that can occur when a
Nodeis created with theNodeBuilder. - Node
List Failure - The failures that can occur when a list of
NodeStates is created withNode::list(). - Node
State - The current state of the
Node. If theNodeis dead all of its resources can be removed withDeadNodeView::remove_stale_resources(). - Node
Wait Failure - The failures that can occur when a list of
NodeStates is created withNode::list().