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