diff options
Diffstat (limited to 'ext/http/slab.rs')
-rw-r--r-- | ext/http/slab.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/ext/http/slab.rs b/ext/http/slab.rs index 9f7c1f3e9..dbe1a6635 100644 --- a/ext/http/slab.rs +++ b/ext/http/slab.rs @@ -32,7 +32,7 @@ pub struct HttpSlabRecord { } thread_local! { - static SLAB: RefCell<Slab<HttpSlabRecord>> = RefCell::new(Slab::with_capacity(1024)); + static SLAB: RefCell<Slab<HttpSlabRecord>> = const { RefCell::new(Slab::new()) }; } macro_rules! http_trace { @@ -56,6 +56,18 @@ pub struct SlabEntry( RefMut<'static, Slab<HttpSlabRecord>>, ); +const SLAB_CAPACITY: usize = 1024; + +pub fn slab_init() { + SLAB.with(|slab: &RefCell<Slab<HttpSlabRecord>>| { + // Note that there might already be an active HTTP server, so this may just + // end up adding room for an additional SLAB_CAPACITY items. All HTTP servers + // on a single thread share the same slab. + let mut slab = slab.borrow_mut(); + slab.reserve(SLAB_CAPACITY); + }) +} + pub fn slab_get(index: SlabId) -> SlabEntry { http_trace!(index, "slab_get"); let mut lock: RefMut<'static, Slab<HttpSlabRecord>> = SLAB.with(|x| { |