]> git.nega.tv - josh/narcissus/commit
Improve pool implementation
authorJoshua Simmons <josh@nega.tv>
Sat, 8 Oct 2022 11:03:44 +0000 (13:03 +0200)
committerJoshua Simmons <josh@nega.tv>
Sat, 8 Oct 2022 11:03:44 +0000 (13:03 +0200)
commit3ad81a357afe3c3292e13a050755ac5d6d3ef2e3
tree25bc336af4ad323792a4d34c2f0081b9d6618671
parent90a190656dcdc5f8344d057fc9918df3a4c38b33
Improve pool implementation

Move virtual memory failures into the `virtual_reserve` and
`virtual_commit` signatures so we can give better assert messages on
failure.

Handle growth more accurately, allowing us to use the entire table
capacity before asserting.

Reserve a bit in the generation counter to keep track of whether a slot
is full by incrementing the counter on both allocation and deallocation.
This means exported handles can only ever have an odd generation
counter.

Assert when given a handle that has an invalid generation counter
(where the counter implies it would be pointing to an empty slot).

Both above changes together means it's no longer possible to create a
reference to an uninitialized slot, even when manually messing with the
handle or mixing handles between different pools.
narcissus-core/src/pool.rs
narcissus-core/src/virtual_mem.rs
narcissus-core/src/virtual_vec/raw_vec.rs