|
98 | 98 | //! to clear the waker field, only steps (i) and (ii) are relevant.
|
99 | 99 | //!
|
100 | 100 | //! 6. The `JoinHandle` can change `JOIN_WAKER` only if COMPLETE is zero (i.e.
|
101 |
| -//! the task hasn't yet completed). |
| 101 | +//! the task hasn't yet completed). The runtime can change `JOIN_WAKER` only |
| 102 | +//! if COMPLETE is one. |
102 | 103 | //!
|
103 | 104 | //! 7. If `JOIN_INTEREST` is zero and COMPLETE is one, then the runtime has
|
104 |
| -//! exclusive (mutable) access to the waker field. |
| 105 | +//! exclusive (mutable) access to the waker field. This might happen if the |
| 106 | +//! `JoinHandle` gets dropped right after the task completes and the runtime |
| 107 | +//! sets the `COMPLETE` bit. In this case the runtime needs the mutable access |
| 108 | +//! to the waker field to drop it. |
105 | 109 | //!
|
106 | 110 | //! Rule 6 implies that the steps (i) or (iii) of rule 5 may fail due to a
|
107 | 111 | //! race. If step (i) fails, then the attempt to write a waker is aborted. If
|
108 | 112 | //! step (iii) fails because COMPLETE is set to one by another thread after
|
109 | 113 | //! step (i), then the waker field is cleared. Once COMPLETE is one (i.e.
|
110 | 114 | //! task has completed), the `JoinHandle` will not modify `JOIN_WAKER`. After the
|
111 |
| -//! runtime sets COMPLETE to one, it invokes the waker if there is one. |
| 115 | +//! runtime sets COMPLETE to one, it invokes the waker if there is one so in this |
| 116 | +//! case when a task completes the `JOIN_WAKER` bit implicates to the runtime |
| 117 | +//! wether it should invoket he waker or not. After the runtime is done with using |
| 118 | +//! the waker during task completion, it unsets the `JOIN_WAKER` bit to give the |
| 119 | +//! `JoinHandle` exclusive access again so that it is able to drop the waker at a |
| 120 | +//! later point. |
112 | 121 | //!
|
113 | 122 | //! All other fields are immutable and can be accessed immutably without
|
114 | 123 | //! synchronization by anyone.
|
|
0 commit comments