pub fn split_work<F>(self, job: F) -> ThreadedWorkMultiplexerHandles
    where
        F: Fn(usize, usize, &ThreadNotifier, &str) + Send + Sync + 'static,
    {
        let mut thread_sync = Vec::with_capacity(self.thread_count as usize);
        // ARC the closure out here, so it is moved just once
        let arc_code = Arc::new(job);
        for i in 0..self.thread_count {
            let (tx, rx) = channel();
            let name = format!("{}.{}", self.thread_base_name, i);

            let total_threads = self.thread_count;
            let notifier = ThreadNotifier::new(rx);
            let thread_name = name.clone();
            let thread_code = Arc::clone(&arc_code);

            let res = thread::Builder::new().name(name).spawn(move || {
                let (time_delta, _) = measure_time(|| {
                    thread_code(i, total_threads, &notifier, thread_name.as_ref());
                });
                log::debug!("{} finished in {} seconds", thread_name, time_delta.as_seconds_f64());
            });
            if let Ok(handle) = res {
                thread_sync.push(Some((tx, handle)));
            } else {
                panic!("Failed to spawn thread {}", i);
            }
        }
        ThreadedWorkMultiplexerHandles { thread_sync }
    }
/// Runs a function or lambda that satisfies the function signature on every thread,
/// effectively distributing work uniformly.
///
/// The function signature, with variable names is essentially:
///
/// `Fn(thread_index: usize, total_threads: usize, notifier: &ThreadNotifier, thread_name:
/// &str)`
///
/// The function is expected to use the `thread_index` and `total_threads` to determine how
/// to shard the work for the current thread. `notifier` should be checked periodically to
/// see if the thread should stop before finishing all of its work. `thread_name` provides
/// the unique name for this thread, for use during logging/debugging.
Runs a function or lambda that satisfies the function signature on every thread,
effectively distributing work uniformly.

The function signature, with variable names is essentially.



The function is expected to use the `thread_index` and `total_threads` to determine how
to shard the work for the current thread. `notifier` should be checked periodically to
see if the thread should stop before finishing all of its work. `thread_name` provides
the unique name for this thread, for use during logging/debugging.
Runs a function or lambda that satisfies the function signature on every thread effectively distributing work uniformly . The function signature with variable names is essentially . The function is expected to use the ` thread_index ` and ` total_threads ` to determine how to shard the work for the current thread . ` notifier ` should be checked periodically to see if the thread should stop before finishing all of its work . ` thread_name ` provides the unique name for this thread for use during logging / debugging .
pub fn split_work<F>(self, job: F) -> ThreadedWorkMultiplexerHandles
    where
        F: Fn(usize, usize, &ThreadNotifier, &str) + Send + Sync + 'static,
    {
        let mut thread_sync = Vec::with_capacity(self.thread_count as usize);
        // ARC the closure out here, so it is moved just once
        let arc_code = Arc::new(job);
        for i in 0..self.thread_count {
            let (tx, rx) = channel();
            let name = format!("{}.{}", self.thread_base_name, i);
            let total_threads = self.thread_count;
            let notifier = ThreadNotifier::new(rx);
            let thread_name = name.clone();
            let thread_code = Arc::clone(&arc_code);
            let res = thread::Builder::new().name(name).spawn(move || {
                let (time_delta, _) = measure_time(|| {
                    thread_code(i, total_threads, &notifier, thread_name.as_ref());
                });
                log::debug!("{} finished in {} seconds", thread_name, time_delta.as_seconds_f64());
            });
            if let Ok(handle) = res {
                thread_sync.push(Some((tx, handle)));
            } else {
                panic!("Failed to spawn thread {}", i);
            }
        }
        ThreadedWorkMultiplexerHandles { thread_sync }
    }
pub fn split_work < F > ( self , job : F ) -> ThreadedWorkMultiplexerHandles where F : Fn ( usize , usize , & ThreadNotifier , & str ) + Send + Sync + ' static , { let mut thread_sync = Vec :: with_capacity ( self . thread_count as usize ) ; // ARC the closure out here, so it is moved just once let arc_code = Arc :: new ( job ) ; for i in 0 .. self . thread_count { let ( tx , rx ) = channel ( ) ; let name = format ! ( " " self thread_base_name i ) ; let total_threads = self . thread_count ; let notifier = ThreadNotifier :: new ( rx ) ; let thread_name = name . clone ( ) ; let thread_code = Arc :: clone ( & arc_code ) ; let res = thread :: Builder :: new ( ) . name ( name ) . spawn ( move | | { let ( time_delta , _ ) = measure_time ( | | { thread_code ( i , total_threads , & notifier , thread_name . as_ref ( ) ) ; } ) ; log :: debug ! ( " " thread_name time_delta as_seconds_f64 ( ) ) ; } ) ; if let Ok ( handle ) = res { thread_sync . push ( Some ( ( tx , handle ) ) ) ; } else { panic ! ( " " i ) ; } } ThreadedWorkMultiplexerHandles { thread_sync } }
Runs a function or lambda that satisfies the function signature on every thread,
effectively distributing work uniformly.
Runs a function or lambda that satisfies the function signature on every thread effectively distributing work uniformly .
self
job
F