Fix update timer handle with 0 millis, do not keep old bucket

This commit is contained in:
Nikolay Kim 2022-02-18 15:20:40 +06:00
parent 2664a2e66d
commit bd18c122b4
5 changed files with 16 additions and 4 deletions

View file

@ -1,5 +1,9 @@
# Changes
## [0.1.15] - 2022-02-18
* Fix update timer handle with 0 millis, do not keep old bucket
## [0.1.14] - 2022-02-18
* time::sleep() always sleeps one tick (16 millis) even for 0 millis

View file

@ -1,6 +1,6 @@
[package]
name = "ntex-util"
version = "0.1.14"
version = "0.1.15"
authors = ["ntex contributors <team@ntex.rs>"]
description = "Utilities for ntex framework"
keywords = ["network", "framework", "async", "futures"]

View file

@ -286,6 +286,7 @@ mod tests {
#[ntex_macros::rt_test2]
async fn system_time_service_time_does_not_immediately_change() {
assert_eq!(system_time(), system_time());
assert_eq!(system_time(), query_system_time());
}
/// State Under Test: `system_time()` updates returned value every 1ms period.
@ -320,6 +321,13 @@ mod tests {
sleep(Millis(1)).await;
let second_time = now();
assert!(second_time - first_time >= time::Duration::from_millis(1));
let first_time = now();
let fut = sleep(Millis(10000));
fut.reset(Millis::ZERO);
fut.await;
let second_time = now();
assert!(second_time - first_time < time::Duration::from_millis(1));
}
#[ntex_macros::rt_test2]

View file

@ -299,8 +299,8 @@ impl Timer {
fn update_timer(inner: &Rc<RefCell<Self>>, hnd: usize, millis: u64) {
let mut slf = inner.borrow_mut();
if millis == 0 {
slf.timers[hnd].bucket = None;
slf.remove_timer_bucket(hnd);
slf.timers[hnd].bucket = None;
return;
}

View file

@ -52,9 +52,9 @@ ntex-codec = "0.6.2"
ntex-router = "0.5.1"
ntex-service = "0.3.1"
ntex-macros = "0.1.3"
ntex-util = "0.1.14"
ntex-util = "0.1.15"
ntex-bytes = "0.1.14"
ntex-tls = "0.1.3"
ntex-tls = "0.1.4"
ntex-rt = "0.4.3"
ntex-io = "0.1.7"
ntex-tokio = "0.1.3"