Skip to content

Commit

Permalink
Implemented slab storage that allocates handles (mozilla#1730)
Browse files Browse the repository at this point in the history
This will be used for passing handles across the FFI.

Use proptest to test the Rust implementation. Created a new fixture to
test foreign bindings code for this.

The docs list list of advantages to this, the main disadvantage is
performance. We need to allocate a vec entry for the pointer and
insert/remove/get need to take a lock.

Compared `Arc<ConcreteType>` this is clearly worse. However, compared to
`Arc<dyn Trait>` it's not so clear when we currently box the arc
before passing it across the FFI.  Compared to the foreign HandleMaps, I
think the new system will be faster.

It seems reasonable to trade some performance for the gains in
simplicity and safety.  The one thing that really bugs me is that
`get()` needs to take a read lock.  I'm pretty sure there's a couple
ways to fix this, but I'm not sure if it's worth the complexity.
  • Loading branch information
bendk committed Oct 18, 2023
1 parent 48b1f51 commit 697819e
Show file tree
Hide file tree
Showing 30 changed files with 1,369 additions and 17 deletions.
225 changes: 222 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ members = [
"examples/traits",

"fixtures/benchmarks",
"fixtures/bindings-internal",
"fixtures/coverall",
"fixtures/callbacks",

Expand Down
Loading

0 comments on commit 697819e

Please sign in to comment.