@@ -123,7 +123,7 @@ impl Dispatcher {
123
123
///
124
124
/// If all threads have panicked, this method will return an error with the
125
125
/// sent closure.
126
- pub fn dispatch < Fut , Fn , R > ( & self , f : Fn ) -> Result < oneshot:: Receiver < R > , SendError < Fn > >
126
+ pub fn dispatch < Fn , Fut , R > ( & self , f : Fn ) -> Result < oneshot:: Receiver < R > , SendError < Fn > >
127
127
where
128
128
Fn : ( FnOnce ( ) -> Fut ) + Send + ' static ,
129
129
Fut : Future < Output = R > + ' static ,
@@ -145,6 +145,25 @@ impl Dispatcher {
145
145
}
146
146
}
147
147
148
+ /// Dispatch a blocking task to the threads.
149
+ ///
150
+ /// Blocking pool of the dispatcher will be obtained from the proactor
151
+ /// builder. So any configuration of the proactor's blocking pool will be
152
+ /// applied to the dispatcher.
153
+ ///
154
+ /// # Error
155
+ ///
156
+ /// If all threads are busy and the thread pool is full, this method will
157
+ /// return an error with the original closure. The limit can be configured
158
+ /// with [`DispatcherBuilder::proactor_builder`] and
159
+ /// [`ProactorBuilder::thread_pool_limit`].
160
+ pub fn dispatch_blocking < Fn > ( & self , f : Fn ) -> Result < ( ) , SendError < Fn > >
161
+ where
162
+ Fn : FnOnce ( ) + Send + ' static ,
163
+ {
164
+ self . pool . dispatch ( f) . map_err ( |f| SendError ( f) )
165
+ }
166
+
148
167
/// Stop the dispatcher and wait for the threads to complete. If there is a
149
168
/// thread panicked, this method will resume the panic.
150
169
pub async fn join ( self ) -> io:: Result < ( ) > {
0 commit comments