MCPcopy Create free account
hub / github.com/NthTensor/Forte / try_enroll_many

Method try_enroll_many

src/thread_pool.rs:827–874  ·  view source on GitHub ↗

Creates multiple memberships for the thread pool.

(&'static self, n: usize)

Source from the content-addressed store, hash-verified

825 self.with_worker(|worker| worker.join(a, b))
826 }
827
828 /// Creates a scope onto which non-static work can be spawned.
829 ///
830 /// See also: [`Worker::scope`] and [`scope`].
831 #[inline(always)]
832 pub fn scope<'env, F, T>(&'static self, f: F) -> T
833 where
834 F: for<'scope> FnOnce(&'scope Scope<'scope, 'env>) -> T,
835 {
836 self.with_worker(|worker| worker.scope(f))
837 }
838
839 /// Runs the same closure on several threads, and returns a vector of
840 /// results.
841 ///
842 /// See also: [`Worker::broadcast`] and [`broadcast`]. If you don't care
843 /// about getting results back, you may want to use
844 /// [`ThreadPool::spawn_broadcast`] instead.
845 #[inline(always)]
846 pub fn broadcast<F, T>(&'static self, f: F) -> Vec<T>
847 where
848 F: for<'w> Fn(Broadcast<'w>) -> T + Sync,
849 T: Send,
850 {
851 self.with_worker(|worker| worker.broadcast(f))
852 }
853
854 /// Runs the same closure on sevearl threads, without waiting for them to
855 /// complete.
856 ///
857 /// See also: [`Worker::spawn_broadcast`] and [`spawn_broadcast`]. If you
858 /// care about getting results back, you may want to use
859 /// [`ThreadPool::broadcast`] instead.
860 #[inline(always)]
861 pub fn spawn_broadcast<F>(&'static self, f: F)
862 where
863 F: for<'w> Fn(Broadcast<'w>) + Send + Sync + 'static,
864 {
865 self.with_worker(|worker| worker.spawn_broadcast(f));
866 }
867}
868
869// -----------------------------------------------------------------------------
870// Worker registration
871
872/// Represents membership in a thread-pool.
873///
874/// Provided by [`ThreadPool::enroll`].
875pub struct Membership {
876 /// The thread pool the worker is registered with.
877 thread_pool: &'static ThreadPool,

Callers 1

resizeMethod · 0.80

Calls 1

get_member_dataMethod · 0.80

Tested by

no test coverage detected