File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -260,3 +260,30 @@ pub fn file_open_tmp(
260
260
}
261
261
}
262
262
}
263
+
264
+ // rustdoc-stripper-ignore-next
265
+ /// Spawn a new infallible `Future` on the thread-default main context.
266
+ ///
267
+ /// This can be called from any thread and will execute the future from the thread
268
+ /// where main context is running, e.g. via a `MainLoop`.
269
+ pub fn spawn_future < R : Send + ' static , F : std:: future:: Future < Output = R > + Send + ' static > (
270
+ f : F ,
271
+ ) -> crate :: JoinHandle < R > {
272
+ let ctx = crate :: MainContext :: ref_thread_default ( ) ;
273
+ ctx. spawn ( f)
274
+ }
275
+
276
+ // rustdoc-stripper-ignore-next
277
+ /// Spawn a new infallible `Future` on the thread-default main context.
278
+ ///
279
+ /// The given `Future` does not have to be `Send`.
280
+ ///
281
+ /// This can be called only from the thread where the main context is running, e.g.
282
+ /// from any other `Future` that is executed on this main context, or after calling
283
+ /// `with_thread_default` or `acquire` on the main context.
284
+ pub fn spawn_future_local < R : ' static , F : std:: future:: Future < Output = R > + ' static > (
285
+ f : F ,
286
+ ) -> crate :: JoinHandle < R > {
287
+ let ctx = crate :: MainContext :: ref_thread_default ( ) ;
288
+ ctx. spawn_local ( f)
289
+ }
You can’t perform that action at this time.
0 commit comments