Add a Rendezvous to this process, returning the handle
(&mut self, rv: Arc<RwLock<Rendezvous>>)
| 91 | /// Add a Rendezvous to this process, returning |
| 92 | /// the handle |
| 93 | fn add_handle(&mut self, rv: Arc<RwLock<Rendezvous>>) -> usize { |
| 94 | // Find if there is an empty handles slot |
| 95 | if let Some(index) = self.handles.iter().position( |
| 96 | |handle| handle.is_none()) { |
| 97 | |
| 98 | // Use empty slot |
| 99 | self.handles[index] = Some(rv); |
| 100 | return index; |
| 101 | } |
| 102 | |
| 103 | // No free slot -> Add one |
| 104 | self.handles.push(Some(rv)); |
| 105 | self.handles.len() - 1 |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | /// Per-thread state |