@@ -286,13 +286,23 @@ where
286
286
/// Spawns a new fiber by taking ownership of the `Builder`, and returns a
287
287
/// [`Result`] to its [`JoinHandle`].
288
288
///
289
+ /// The current fiber performs a **yield** and the execution is transfered
290
+ /// to the new fiber immediately.
291
+ ///
289
292
/// See the [`start`] free function for more details.
290
293
pub fn start ( self ) -> Result < C :: JoinHandle > {
291
294
inner_spawn ! ( self , immediate)
292
295
}
293
296
294
- /// Spawns a new deferred fiber by taking ownership of the `Builder`,
295
- /// and returns a [`Result`] to its [`JoinHandle`].
297
+ #[ cfg( feature = "defer" ) ]
298
+ /// Spawns a new deferred fiber by taking ownership of the `Builder`, and
299
+ /// returns a [`Result`] to its [`JoinHandle`].
300
+ ///
301
+ /// **NOTE:** In the current implementation the current fiber performs a
302
+ /// **yield** to start the newly created fiber and then the new fiber
303
+ /// performs another **yield**. This means that the deferred fiber is **not
304
+ /// applicable for transactions** (which do not allow any context switches).
305
+ /// In the future we are planning to add a correct implementation.
296
306
///
297
307
/// See the [`defer`] free function for more details.
298
308
pub fn defer ( self ) -> Result < C :: JoinHandle > {
@@ -634,8 +644,8 @@ impl TrampolineArgs for VaList {
634
644
// Free functions
635
645
////////////////////////////////////////////////////////////////////////////////
636
646
637
- /// Creates a new fiber and runs it immediately, returning a [`JoinHandle`] for
638
- /// it .
647
+ /// Creates a new fiber and **yields** execution to it immediately, returning a
648
+ /// [`JoinHandle`] for the new fiber .
639
649
///
640
650
/// **NOTE**: The argument `f` is a function that returns `T`. In case when `T =
641
651
/// ()` (no return value) one should instead use [`start_proc`].
@@ -655,10 +665,10 @@ where
655
665
Builder :: new ( ) . func ( f) . start ( ) . unwrap ( )
656
666
}
657
667
658
- /// Creates a new unit fiber and runs it immediately, returning a
659
- /// [`UnitJoinHandle`] for it .
668
+ /// Creates a new proc fiber and **yields** execution to it immediately,
669
+ /// returning a [`UnitJoinHandle`] for the new fiber .
660
670
///
661
- /// The *unit fiber* is a special case of a fiber whose function does not return
671
+ /// The *proc fiber* is a special case of a fiber whose function does not return
662
672
/// a value. In fact `UnitJoinHandle` is identical to `JoinHanble<()>` is all
663
673
/// aspects instead that it is implemented more efficiently and the former
664
674
/// should always be used instead of the latter.
@@ -671,26 +681,40 @@ where
671
681
Builder :: new ( ) . proc ( f) . start ( ) . unwrap ( )
672
682
}
673
683
674
- /// Creates and schedules a new deferred fiber, returning a [`JoinHandle`] for
675
- /// it.
684
+ #[ cfg( any( feature = "defer" , doc) ) ]
685
+ /// Creates a new fiber and schedules it for exeution, returning a
686
+ /// [`JoinHandle`] for it.
687
+ ///
688
+ /// **NOTE:** In the current implementation the current fiber performs a
689
+ /// **yield** to start the newly created fiber and then the new fiber
690
+ /// performs another **yield**. This means that the deferred fiber is **not
691
+ /// applicable for transactions** (which do not allow any context switches).
692
+ /// In the future we are planning to add a correct implementation.
676
693
///
677
694
/// **NOTE**: The argument `f` is a function that returns `T`. In case when `T =
678
695
/// ()` (no return value) one should instead use [`defer_proc`].
679
696
///
680
- /// The **deferred fiber** is a fiber which starts in a detached mode. It can be
681
- /// joined by calling the [`JoinHandle:: join`] method .
697
+ /// The new fiber can be joined by calling [`JoinHandle::join`] method on it's
698
+ /// join handle .
682
699
pub fn defer < F , T > ( f : F ) -> JoinHandle < T >
683
700
where
684
701
F : FnOnce ( ) -> T ,
685
702
{
686
703
Builder :: new ( ) . func ( f) . defer ( ) . unwrap ( )
687
704
}
688
705
689
- /// Creates and schedules a new deferred unit fiber, returning a
706
+ #[ cfg( any( feature = "defer" , doc) ) ]
707
+ /// Creates a new proc fiber and schedules it for exeution, returning a
690
708
/// [`UnitJoinHandle`] for it.
691
709
///
692
- /// The **deferred unit fiber** is a fiber which starts in a detached mode. It
693
- /// can be joined by calling the [`UnitJoinHandle::join`] method.
710
+ /// **NOTE:** In the current implementation the current fiber performs a
711
+ /// **yield** to start the newly created fiber and then the new fiber performs
712
+ /// another **yield**. This means that the deferred fiber is **not applicable
713
+ /// for transactions** (which do not allow any context switches). In the future
714
+ /// we are planning to add a correct implementation.
715
+ ///
716
+ /// The new fiber can be joined by calling [`UnitJoinHandle::join`] method on
717
+ /// it's join handle.
694
718
///
695
719
/// This is an optimized version [`defer`]`<F, ()>`.
696
720
pub fn defer_proc < F > ( f : F ) -> UnitJoinHandle
0 commit comments