Macro enhanced_share

Source
macro_rules! enhanced_share {
    ($data:expr) => { ... };
}
Expand description

Macro for creating enhanced thread share with automatic thread management

This macro creates an EnhancedThreadShare<T> instance that provides automatic thread management capabilities.

§Syntax

enhanced_share!(expression)

§Arguments

  • expression - The data to wrap in EnhancedThreadShare

§Returns

A new EnhancedThreadShare<T> instance where T is inferred from the expression.

§Example

use thread_share::enhanced_share;

// Basic types
let counter = enhanced_share!(0);                    // EnhancedThreadShare<i32>
let message = enhanced_share!(String::from("Hello")); // EnhancedThreadShare<String>
let data = enhanced_share!(vec![1, 2, 3]);          // EnhancedThreadShare<Vec<i32>>

§Key Features

  • Automatic Thread Management: Spawn threads with a single method call
  • Built-in Thread Tracking: Monitor active thread count and status
  • Automatic Thread Joining: Wait for all threads to complete with join_all()
  • Thread Naming: Give meaningful names to threads for debugging
  • All ThreadShare Features: Inherits all capabilities from ThreadShare<T>

§When to Use

Use enhanced_share! when you need:

  • Complex multi-threaded applications
  • Automatic thread lifecycle management
  • Thread monitoring and debugging
  • High-level thread coordination

Use share! when you need:

  • Simple data sharing without thread management
  • Manual thread control
  • Minimal overhead