1
0
Fork 0
forked from wry/wry

autocommit 2022-03-30 03:00:46 CEST

This commit is contained in:
Julian Orth 2022-03-30 03:00:46 +02:00
parent 9842264fad
commit 28c9b46400
40 changed files with 1212 additions and 175 deletions

View file

@ -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 {