Close a Rendezvous. If a thread was waiting then it is returned and should be scheduled. An error SYSCALL_ERROR_CLOSED will be returned to the waiting thread.
(&mut self)
| 196 | /// If a thread was waiting then it is returned and should be scheduled. |
| 197 | /// An error SYSCALL_ERROR_CLOSED will be returned to the waiting thread. |
| 198 | pub fn close(&mut self) -> Option<Box<Thread>> { |
| 199 | match &*self { |
| 200 | Rendezvous::Empty => None, |
| 201 | Rendezvous::Sending(_, _) => { |
| 202 | // Cannot complete the message transfer |
| 203 | if let Rendezvous::Sending(Some(snd_thread), message) = mem::replace(self, Rendezvous::Empty) { |
| 204 | snd_thread.return_error_message(syscalls::SYSCALL_ERROR_CLOSED, message); |
| 205 | Some(snd_thread) |
| 206 | } else { |
| 207 | None |
| 208 | } |
| 209 | } |
| 210 | Rendezvous::Receiving(_, _) => { |
| 211 | // Will never receive a message |
| 212 | if let Rendezvous::Receiving(rec_thread, _) = mem::replace(self, Rendezvous::Empty) { |
| 213 | rec_thread.return_error(syscalls::SYSCALL_ERROR_CLOSED); |
| 214 | Some(rec_thread) |
| 215 | } else { |
| 216 | None |
| 217 | } |
| 218 | } |
| 219 | Rendezvous::SendReceiving(_, _) => { |
| 220 | // Cannot complete the message transfer |
| 221 | if let Rendezvous::SendReceiving(snd_thread, message) = mem::replace(self, Rendezvous::Empty) { |
| 222 | snd_thread.return_error_message(syscalls::SYSCALL_ERROR_CLOSED, message); |
| 223 | Some(snd_thread) |
| 224 | } else { |
| 225 | None |
| 226 | } |
| 227 | } |
| 228 | } |
| 229 | } |
| 230 | } |
no test coverage detected