compio-rs / compio

A thread-per-core Rust runtime with IOCP/io_uring/polling.
MIT License
420 stars 37 forks source link

Relax IOBuf lifetime to driver's lifetime #55

Closed DXist closed 1 year ago

DXist commented 1 year ago

'static lifetime bound for IOBuf is too restrictive and doesn't play nicely with buffers allocated from an arena allocator.

Is it possible to relax it to driver's lifetime? The expectation is that buffer pool lifetime is larger than driver's lifetime.

Berrysoft commented 1 year ago

We need the ownership of the buffer. A reference is not enough, except a static reference. If you insist using a short lifetime, you can implement it yourself.

DXist commented 1 year ago

We can own buffer, allocated from not 'static arena allocator, like

let io_page_aligned_arena_alloc = ...;
let buf = Vec::with_capacity_in(IO_PAGE_SIZE * 4, &io_page_aligned_arena_alloc);
Berrysoft commented 1 year ago

That needs nightly feature. Open a PR if you would like.