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 {
109
109
crate :: registry:: Registry :: current_num_threads ( )
110
110
}
111
111
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
+
112
121
/// Error when initializing a thread pool.
113
122
#[ derive( Debug ) ]
114
123
pub struct ThreadPoolBuildError {
Original file line number Diff line number Diff line change @@ -252,6 +252,12 @@ impl ThreadPool {
252
252
// We assert that `self.registry` has not terminated.
253
253
unsafe { spawn:: spawn_fifo_in ( op, & self . registry ) }
254
254
}
255
+
256
+ /// Returns the current threadpool.
257
+ pub fn current ( ) -> ThreadPool {
258
+ let registry = crate :: registry:: Registry :: current ( ) ;
259
+ ThreadPool { registry }
260
+ }
255
261
}
256
262
257
263
impl Drop for ThreadPool {
Original file line number Diff line number Diff line change @@ -114,7 +114,7 @@ pub use rayon_core::ThreadBuilder;
114
114
pub use rayon_core:: ThreadPool ;
115
115
pub use rayon_core:: ThreadPoolBuildError ;
116
116
pub 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} ;
118
118
pub use rayon_core:: { join, join_context} ;
119
119
pub use rayon_core:: { scope, Scope } ;
120
120
pub use rayon_core:: { scope_fifo, ScopeFifo } ;
You can’t perform that action at this time.
0 commit comments