MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / with_config

Method with_config

nodedb/src/data/io/uring_reader.rs:66–91  ·  view source on GitHub ↗

Create with custom configuration.

(queue_depth: u32, pool_size: usize, buf_size: usize)

Source from the content-addressed store, hash-verified

64
65 /// Create with custom configuration.
66 pub fn with_config(queue_depth: u32, pool_size: usize, buf_size: usize) -> Option<Self> {
67 let ring = io_uring::IoUring::new(queue_depth).ok()?;
68
69 let mut pool = Vec::with_capacity(pool_size);
70 let mut free = Vec::with_capacity(pool_size);
71 for i in 0..pool_size {
72 match AlignedBuf::new(buf_size) {
73 Ok(buf) => {
74 pool.push(buf);
75 free.push(i);
76 }
77 Err(_) => break,
78 }
79 }
80
81 if pool.is_empty() {
82 return None;
83 }
84
85 Some(Self {
86 ring,
87 pool,
88 free,
89 buf_size,
90 })
91 }
92
93 /// Read multiple files in a single batched io_uring submission.
94 ///

Callers 1

newMethod · 0.45

Calls 3

okMethod · 0.45
pushMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected