mirror of
https://github.com/ntex-rs/ntex.git
synced 2025-04-04 13:27:39 +03:00
optimize time
This commit is contained in:
parent
73c9672fee
commit
aeefa92d34
1 changed files with 10 additions and 12 deletions
|
@ -186,13 +186,12 @@ impl TimerInner {
|
||||||
let bucket_entry = bucket.add_entry(no);
|
let bucket_entry = bucket.add_entry(no);
|
||||||
|
|
||||||
entry.insert(TimerEntry {
|
entry.insert(TimerEntry {
|
||||||
no,
|
|
||||||
bucket_entry,
|
bucket_entry,
|
||||||
bucket: idx as u16,
|
bucket: idx as u16,
|
||||||
task: LocalWaker::new(),
|
task: LocalWaker::new(),
|
||||||
flags: TimerEntryFlags::empty(),
|
flags: TimerEntryFlags::empty(),
|
||||||
});
|
});
|
||||||
slf.occupied[bucket.lvl] |= bucket.bit;
|
slf.occupied[bucket.lvl as usize] |= bucket.bit;
|
||||||
(no, bucket_expiry)
|
(no, bucket_expiry)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -237,18 +236,18 @@ impl TimerInner {
|
||||||
let b = &mut slf.buckets[entry.bucket as usize];
|
let b = &mut slf.buckets[entry.bucket as usize];
|
||||||
b.entries.remove(entry.bucket_entry);
|
b.entries.remove(entry.bucket_entry);
|
||||||
if b.entries.is_empty() {
|
if b.entries.is_empty() {
|
||||||
slf.occupied[b.lvl] &= b.bit_n;
|
slf.occupied[b.lvl as usize] &= b.bit_n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let bucket = &mut slf.buckets[idx];
|
let bucket = &mut slf.buckets[idx];
|
||||||
let bucket_entry = bucket.add_entry(entry.no);
|
let bucket_entry = bucket.add_entry(hnd);
|
||||||
|
|
||||||
entry.bucket = idx as u16;
|
entry.bucket = idx as u16;
|
||||||
entry.bucket_entry = bucket_entry;
|
entry.bucket_entry = bucket_entry;
|
||||||
entry.flags = TimerEntryFlags::empty();
|
entry.flags = TimerEntryFlags::empty();
|
||||||
|
|
||||||
slf.occupied[bucket.lvl] |= bucket.bit;
|
slf.occupied[bucket.lvl as usize] |= bucket.bit;
|
||||||
bucket_expiry
|
bucket_expiry
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -273,7 +272,7 @@ impl TimerInner {
|
||||||
let b = &mut self.buckets[entry.bucket as usize];
|
let b = &mut self.buckets[entry.bucket as usize];
|
||||||
b.entries.remove(entry.bucket_entry);
|
b.entries.remove(entry.bucket_entry);
|
||||||
if b.entries.is_empty() {
|
if b.entries.is_empty() {
|
||||||
self.occupied[b.lvl] &= b.bit_n;
|
self.occupied[b.lvl as usize] &= b.bit_n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -335,7 +334,7 @@ impl TimerInner {
|
||||||
let idx = (clk & LVL_MASK) + lvl * LVL_SIZE;
|
let idx = (clk & LVL_MASK) + lvl * LVL_SIZE;
|
||||||
let b = &mut self.buckets[idx as usize];
|
let b = &mut self.buckets[idx as usize];
|
||||||
if !b.entries.is_empty() {
|
if !b.entries.is_empty() {
|
||||||
self.occupied[b.lvl] &= b.bit_n;
|
self.occupied[b.lvl as usize] &= b.bit_n;
|
||||||
for no in b.entries.drain() {
|
for no in b.entries.drain() {
|
||||||
if let Some(timer) = self.timers.get_mut(no) {
|
if let Some(timer) = self.timers.get_mut(no) {
|
||||||
timer.complete();
|
timer.complete();
|
||||||
|
@ -401,8 +400,8 @@ impl TimerInner {
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct Bucket {
|
struct Bucket {
|
||||||
lvl: usize,
|
lvl: u32,
|
||||||
offs: u64,
|
offs: u32,
|
||||||
bit: u64,
|
bit: u64,
|
||||||
bit_n: u64,
|
bit_n: u64,
|
||||||
entries: Slab<usize>,
|
entries: Slab<usize>,
|
||||||
|
@ -418,9 +417,9 @@ impl Bucket {
|
||||||
fn new(lvl: usize, offs: usize) -> Self {
|
fn new(lvl: usize, offs: usize) -> Self {
|
||||||
let bit = 1 << (offs as u64);
|
let bit = 1 << (offs as u64);
|
||||||
Bucket {
|
Bucket {
|
||||||
lvl,
|
|
||||||
bit,
|
bit,
|
||||||
offs: offs as u64,
|
lvl: lvl as u32,
|
||||||
|
offs: offs as u32,
|
||||||
bit_n: !bit,
|
bit_n: !bit,
|
||||||
entries: Slab::default(),
|
entries: Slab::default(),
|
||||||
}
|
}
|
||||||
|
@ -436,7 +435,6 @@ bitflags::bitflags! {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct TimerEntry {
|
struct TimerEntry {
|
||||||
flags: TimerEntryFlags,
|
flags: TimerEntryFlags,
|
||||||
no: usize,
|
|
||||||
bucket: u16,
|
bucket: u16,
|
||||||
bucket_entry: usize,
|
bucket_entry: usize,
|
||||||
task: LocalWaker,
|
task: LocalWaker,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue