autocommit 2022-03-30 03:00:46 CEST
This commit is contained in:
parent
9842264fad
commit
28c9b46400
40 changed files with 1212 additions and 175 deletions
|
|
@ -10,6 +10,15 @@ pub struct Bitfield {
|
|||
}
|
||||
|
||||
impl Bitfield {
|
||||
pub fn take(&mut self, val: u32) {
|
||||
let idx = val as usize / SEG_SIZE;
|
||||
let pos = val as usize % SEG_SIZE;
|
||||
while self.vals.len() <= idx {
|
||||
self.vals.push(0);
|
||||
}
|
||||
self.vals[idx] &= !(1 << pos);
|
||||
}
|
||||
|
||||
pub fn acquire(&mut self) -> u32 {
|
||||
for (idx, n) in self.vals.iter_mut().enumerate() {
|
||||
if *n != 0 {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::async_engine::AsyncError;
|
||||
pub use buf_in::BufFdIn;
|
||||
pub use buf_out::{BufFdOut, OutBufferSwapchain};
|
||||
pub use buf_out::{BufFdOut, OutBuffer, OutBufferSwapchain};
|
||||
pub use formatter::MsgFormatter;
|
||||
pub use parser::{MsgParser, MsgParserError};
|
||||
use thiserror::Error;
|
||||
|
|
|
|||
|
|
@ -112,6 +112,17 @@ impl BufFdOut {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn flush_no_timeout(&mut self, buf: &mut OutBuffer) -> Result<(), BufFdError> {
|
||||
while buf.read_pos < buf.write_pos {
|
||||
if self.flush_sync(buf)? {
|
||||
self.fd.writable().await?;
|
||||
}
|
||||
}
|
||||
buf.read_pos = 0;
|
||||
buf.write_pos = 0;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn flush_sync(&mut self, buffer: &mut OutBuffer) -> Result<bool, BufFdError> {
|
||||
while buffer.read_pos < buffer.write_pos {
|
||||
let mut buf = unsafe { &(*buffer.buf)[buffer.read_pos..buffer.write_pos] };
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ impl<'a, 'b> MsgParser<'a, 'b> {
|
|||
Self {
|
||||
buf,
|
||||
pos: 0,
|
||||
data: unsafe { std::slice::from_raw_parts(data.as_ptr() as *const u8, data.len() * 4) },
|
||||
data: uapi::as_bytes(data),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue