| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Wireform.Ring.Pool
Description
A pool of pre-allocated MagicRing buffers for reuse.
Allocating a magic ring costs memfd_create + ftruncate + 3×
mmap + memset per ring. This pool keeps a bounded free list of
rings so connection churn doesn't repeat that syscall work.
Rings are stored as raw (Ptr Word8, Int) pairs — no IORefs, no
per-ring mutable state. The transport-layer cursor state (head,
tail, open/closed) is always fresh per connection; only the
underlying mmap'd memory is recycled.
Synopsis
- data RingPool
- data RingPoolConfig = RingPoolConfig {
- ringPoolMaxIdle :: !Int
- defaultRingPoolConfig :: RingPoolConfig
- newRingPool :: RingPoolConfig -> IO RingPool
- closeRingPool :: RingPool -> IO ()
- acquireRing :: forall {k} (s :: k). RingPool -> Int -> IO (MagicRing s)
- releaseRing :: forall {k} (s :: k). RingPool -> MagicRing s -> IO ()
Documentation
The pool is just a bounded free list protected by an MVar. All rings in the list have the same allocated size (the first allocation's rounded-up size sets the class).
data RingPoolConfig Source #
Constructors
| RingPoolConfig | |
Fields
| |
newRingPool :: RingPoolConfig -> IO RingPool Source #
closeRingPool :: RingPool -> IO () Source #
Destroy all idle rings. The pool remains usable (acquire allocates fresh, release destroys immediately).