File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
Expand file tree Collapse file tree 2 files changed +15
-0
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 {
You can’t perform that action at this time.
0 commit comments