mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 09:31:22 -05:00
feat(core): add unregister op (#6214)
This commit is contained in:
parent
15cfe9e6e5
commit
1b6a8051b9
1 changed files with 9 additions and 0 deletions
|
@ -64,6 +64,11 @@ impl OpRegistry {
|
|||
pub fn get(&self, op_id: OpId) -> Option<Rc<OpDispatcher>> {
|
||||
self.dispatchers.get(op_id as usize).map(Rc::clone)
|
||||
}
|
||||
|
||||
pub fn unregister_op(&mut self, name: &str) {
|
||||
let id = self.name_to_id.remove(name).unwrap();
|
||||
drop(self.dispatchers.remove(id as usize));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -101,6 +106,10 @@ fn test_op_registry() {
|
|||
assert_eq!(c.load(atomic::Ordering::SeqCst), 1);
|
||||
|
||||
assert!(op_registry.get(100).is_none());
|
||||
op_registry.unregister_op("test");
|
||||
expected.remove("test");
|
||||
assert_eq!(op_registry.name_to_id, expected);
|
||||
assert!(op_registry.get(1).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Add table
Reference in a new issue