@@ -268,9 +268,24 @@ pub fn file_open_tmp(
268
268
/// where main context is running, e.g. via a `MainLoop`.
269
269
pub fn spawn_future < R : Send + ' static , F : std:: future:: Future < Output = R > + Send + ' static > (
270
270
f : F ,
271
+ ) -> crate :: JoinHandle < R > {
272
+ spawn_future_with_priority ( crate :: source:: Priority :: DEFAULT , f)
273
+ }
274
+
275
+ // rustdoc-stripper-ignore-next
276
+ /// Spawn a new infallible `Future` on the main context, with a non-default priority.
277
+ ///
278
+ /// This can be called from any thread and will execute the future from the thread
279
+ /// where main context is running, e.g. via a `MainLoop`.
280
+ pub fn spawn_future_with_priority <
281
+ R : Send + ' static ,
282
+ F : std:: future:: Future < Output = R > + Send + ' static ,
283
+ > (
284
+ priority : crate :: source:: Priority ,
285
+ f : F ,
271
286
) -> crate :: JoinHandle < R > {
272
287
let ctx = crate :: MainContext :: ref_thread_default ( ) ;
273
- ctx. spawn ( f)
288
+ ctx. spawn_with_priority ( priority , f)
274
289
}
275
290
276
291
// rustdoc-stripper-ignore-next
@@ -283,7 +298,25 @@ pub fn spawn_future<R: Send + 'static, F: std::future::Future<Output = R> + Send
283
298
/// `with_thread_default` or `acquire` on the main context.
284
299
pub fn spawn_future_local < R : ' static , F : std:: future:: Future < Output = R > + ' static > (
285
300
f : F ,
301
+ ) -> crate :: JoinHandle < R > {
302
+ spawn_future_local_with_priority ( crate :: source:: Priority :: DEFAULT , f)
303
+ }
304
+
305
+ // rustdoc-stripper-ignore-next
306
+ /// Spawn a new infallible `Future` on the main context, with a non-default priority.
307
+ ///
308
+ /// The given `Future` does not have to be `Send`.
309
+ ///
310
+ /// This can be called only from the thread where the main context is running, e.g.
311
+ /// from any other `Future` that is executed on this main context, or after calling
312
+ /// `with_thread_default` or `acquire` on the main context.
313
+ pub fn spawn_future_local_with_priority <
314
+ R : ' static ,
315
+ F : std:: future:: Future < Output = R > + ' static ,
316
+ > (
317
+ priority : crate :: source:: Priority ,
318
+ f : F ,
286
319
) -> crate :: JoinHandle < R > {
287
320
let ctx = crate :: MainContext :: ref_thread_default ( ) ;
288
- ctx. spawn_local ( f)
321
+ ctx. spawn_local_with_priority ( priority , f)
289
322
}
0 commit comments