Create with custom configuration.
(queue_depth: u32, pool_size: usize, buf_size: usize)
| 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 | /// |