this repo has no description
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

pool: add comment

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>

+13
+13
src/pool.zig
··· 3 3 const Condition = std.Thread.Condition; 4 4 const Mutex = std.Thread.Mutex; 5 5 6 + /// BytePool is a thread safe buffer. Use it by Allocating a given number of bytes, which will block 7 + /// until one is available. The returned Slice structure contains a reference to a slice within the 8 + /// pool. This slice will always belong to the Slice until deinit is called. 9 + /// 10 + /// This data structure is useful for receiving messages over-the-wire and sending to another thread 11 + /// for processing, while providing some level of backpressure on the read side. For example, we 12 + /// could be reading messages from the wire and sending into a queue for processing. We could read 13 + /// 10 messages off the connection, but the queue is blocked doing an expensive operation. We are 14 + /// still able to read until our BytePool is out of capacity. 15 + /// 16 + /// For IRC, we use this because messages over the wire *could* be up to 4192 bytes, but commonly 17 + /// are less than 100. Instead of a pool of buffers each 4192, we write messages of exact length 18 + /// into this pool to more efficiently pack the memory 6 19 pub fn BytePool(comptime size: usize) type { 7 20 return struct { 8 21 const Self = @This();