1
0
Fork 0
forked from wry/wry

autocommit 2022-03-11 19:24:53 CET

This commit is contained in:
Julian Orth 2022-03-11 19:24:53 +01:00
parent b1890894b2
commit 0ae73ab9c4
9 changed files with 277 additions and 66 deletions

View file

@ -21,3 +21,4 @@ pub mod tri;
pub mod vasprintf;
pub mod vec_ext;
pub mod vecstorage;
pub mod nonblock;

8
src/utils/nonblock.rs Normal file
View file

@ -0,0 +1,8 @@
use uapi::{c};
use crate::utils::oserror::OsError;
pub fn set_nonblock(fd: c::c_int) -> Result<(), OsError> {
let fl = uapi::fcntl_getfl(fd)?;
uapi::fcntl_setfl(fd, fl | c::SOCK_NONBLOCK)?;
Ok(())
}

View file

@ -24,4 +24,8 @@ impl<T> SyncQueue<T> {
pub fn pop(&self) -> Option<T> {
unsafe { self.el.get().deref_mut().pop_front() }
}
pub fn is_empty(&self) -> bool {
unsafe { self.el.get().deref_mut().is_empty() }
}
}