File tree Expand file tree Collapse file tree 3 files changed +16
-1
lines changed
Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -109,6 +109,15 @@ pub fn current_num_threads() -> usize {
109109 crate :: registry:: Registry :: current_num_threads ( )
110110}
111111
112+ /// Returns the current threadpool.
113+ ///
114+ /// It is a shorthand for [`Threadpool::current()`][tc].
115+ ///
116+ /// [tc]: struct.ThreadPool.html#method.current
117+ pub fn current ( ) -> ThreadPool {
118+ ThreadPool :: current ( )
119+ }
120+
112121/// Error when initializing a thread pool.
113122#[ derive( Debug ) ]
114123pub struct ThreadPoolBuildError {
Original file line number Diff line number Diff line change @@ -252,6 +252,12 @@ impl ThreadPool {
252252 // We assert that `self.registry` has not terminated.
253253 unsafe { spawn:: spawn_fifo_in ( op, & self . registry ) }
254254 }
255+
256+ /// Returns the current threadpool.
257+ pub fn current ( ) -> ThreadPool {
258+ let registry = crate :: registry:: Registry :: current ( ) ;
259+ ThreadPool { registry }
260+ }
255261}
256262
257263impl Drop for ThreadPool {
Original file line number Diff line number Diff line change @@ -114,7 +114,7 @@ pub use rayon_core::ThreadBuilder;
114114pub use rayon_core:: ThreadPool ;
115115pub use rayon_core:: ThreadPoolBuildError ;
116116pub use rayon_core:: ThreadPoolBuilder ;
117- pub use rayon_core:: { current_num_threads, current_thread_index} ;
117+ pub use rayon_core:: { current , current_num_threads, current_thread_index} ;
118118pub use rayon_core:: { join, join_context} ;
119119pub use rayon_core:: { scope, Scope } ;
120120pub use rayon_core:: { scope_fifo, ScopeFifo } ;
You can’t perform that action at this time.
0 commit comments