Move this `Waitable` to the specified set (when `set` is `Some(_)`) or remove it from any set it may currently belong to (when `set` is `None`).
(&self, state: &mut ConcurrentState, set: Option<TableId<WaitableSet>>)
| 4818 | /// remove it from any set it may currently belong to (when `set` is |
| 4819 | /// `None`). |
| 4820 | fn join(&self, state: &mut ConcurrentState, set: Option<TableId<WaitableSet>>) -> Result<()> { |
| 4821 | log::trace!("waitable {self:?} join set {set:?}"); |
| 4822 | |
| 4823 | let old = mem::replace(&mut self.common(state)?.set, set); |
| 4824 | |
| 4825 | if let Some(old) = old { |
| 4826 | match *self { |
| 4827 | Waitable::Host(id) => state.remove_child(id, old), |
| 4828 | Waitable::Guest(id) => state.remove_child(id, old), |
| 4829 | Waitable::Transmit(id) => state.remove_child(id, old), |
| 4830 | }?; |
| 4831 | |
| 4832 | state.get_mut(old)?.ready.remove(self); |
| 4833 | } |
| 4834 | |
| 4835 | if let Some(set) = set { |
| 4836 | match *self { |
| 4837 | Waitable::Host(id) => state.add_child(id, set), |
| 4838 | Waitable::Guest(id) => state.add_child(id, set), |
| 4839 | Waitable::Transmit(id) => state.add_child(id, set), |
| 4840 | }?; |
| 4841 | |
| 4842 | if self.common(state)?.event.is_some() { |
| 4843 | self.mark_ready(state)?; |
| 4844 | } |
| 4845 | } |
| 4846 | |
| 4847 | Ok(()) |
| 4848 | } |
| 4849 | |
| 4850 | /// Retrieve mutable access to the `WaitableCommon` for this `Waitable`. |
| 4851 | fn common<'a>(&self, state: &'a mut ConcurrentState) -> Result<&'a mut WaitableCommon> { |