Skip to content

Threading

Christian edited this page Jun 15, 2026 · 3 revisions

We utilize different threads and mix smol with tokio. Mid-term we want to get rid of tokio for the ethercat part but keep it for axum (REST) and socketioxide (SocketIO).

Threads

Main Thread from server::main::main

Main thread that inits the program and starts the other threads.

Listend to a channel for panics other threads can send via the send_panic function. If the main thread recieves the panic signal it exits (exit(1)) the program.

ApiThread from server::rest::init::start_api_thread

Creates a tokio runtime for the init_api function which starts the axum & socketioxide servers.

Used send_panic to exit program if this thread panics.

Ethercat Interface Test Threads from server::ethercat::setup::setup_loop

Tests different network interfaces sequentially to find the EtherCAT master.

Uses Smol LocalExecutor.

LoopThread from server::r#loop::start_loop_thread

Uses thread-local smol runtime.

Runs the main control loop.

Used send_panic to exit program if this thread panics.

TODO: Should use realtime priority.

EthercatTxRxThread from server::ethercat::setup::setup_loop

Runs the Ethercrab TX/RX loop.

TODO: Should use realtime priority.

Used send_panic to exit program if this thread panics.

Clone this wiki locally