Remove a plugin based on its type
(&self, plugin_type: CollabPluginType)
| 176 | |
| 177 | // Remove a plugin based on its type |
| 178 | pub fn remove_plugin(&self, plugin_type: CollabPluginType) { |
| 179 | let inner = &*self.0; |
| 180 | let mut current = inner.head.load_full(); |
| 181 | let mut prev: Option<Arc<Node>> = None; |
| 182 | |
| 183 | while let Some(curr_node) = current { |
| 184 | if curr_node.value.plugin_type() == plugin_type { |
| 185 | let next = curr_node.next.load_full(); |
| 186 | match prev { |
| 187 | Some(prev_node) => { |
| 188 | prev_node.next.store(next); // Bypass the current node |
| 189 | }, |
| 190 | None => { |
| 191 | inner.head.swap(next); // Removing the head node |
| 192 | }, |
| 193 | } |
| 194 | |
| 195 | trace!("Removed plugin: {:?}", plugin_type); |
| 196 | curr_node.value.destroy(); |
| 197 | return; |
| 198 | } |
| 199 | |
| 200 | prev = Some(curr_node.clone()); |
| 201 | current = curr_node.next.load_full(); |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | // Push a plugin to the front of the list |
| 206 | pub fn push_front(&self, plugin: Box<dyn CollabPlugin>) -> bool { |