Skip to content

Commit

Permalink
Avoid taking a write lock in RegisteredType::{root,clone,drop}
Browse files Browse the repository at this point in the history
By moving the registration count into the `Arc`, that is pulling the `Arc`
outwards from containing just the `WasmFuncType` to the registration count as
well, and turning it into an atomic, we can manipulate the registration count
without a write lock. Once that is done, we have the following:

* `RegisteredType::root` only needs a read lock, not a write lock.

* `RegisteredType::clone`, which used to need a write lock, doesn't need any
  locking anymore.

* `RegisteredType::drop` doesn't need any locking most of the time. The
  exception is when this is this drop that moves the refcount to zero, in which
  case grabbing a write lock is still necessary to remove the type from the
  registry.
  • Loading branch information
fitzgen committed Feb 20, 2024
1 parent ff93bce commit 6244e73
Showing 1 changed file with 207 additions and 156 deletions.
Loading

0 comments on commit 6244e73

Please sign in to comment.