Macro thread_setup

Source
macro_rules! thread_setup {
    ($shared_data:expr, { $($name:ident: $func:expr),* }) => { ... };
}
Expand description

Macro for creating a complete thread setup

This macro creates a ThreadManager and spawns multiple threads with shared data in a single call, returning the manager for further control.

§Syntax

thread_setup!(shared_data, { name: function, ... })

§Arguments

  • shared_data - The ThreadShare data to share
  • { name: function, ... } - Named thread functions

§Returns

A ThreadManager instance that can be used to control the spawned threads.

§Example

use thread_share::{share, thread_setup};

let data = share!(0);

let manager = thread_setup!(data, {
    counter: |data| { data.update(|x| *x += 1); },
    monitor: |data| { println!("Value: {}", data.get()); }
});

// Wait for all threads
manager.join_all().expect("Failed to join threads");