Commit 4db1e701 authored by Stefan Lankes's avatar Stefan Lankes
Browse files

using ScopeGuards to increase the readability

parent 51162e19
......@@ -184,10 +184,17 @@ dependencies = [
"num",
"num-derive",
"num-traits",
"scopeguard",
"x86",
"x86_64",
]
[[package]]
name = "scopeguard"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "semver"
version = "0.9.0"
......
......@@ -48,6 +48,10 @@ acpi = []
x86_64 = "0.11.0"
float-cmp = "0.8.0"
[dependencies.scopeguard]
version = "1.1"
default-features = false
[dev-dependencies.num-traits]
version = "0.2"
default-features = false
......
......@@ -61,6 +61,7 @@ extern crate num;
#[macro_use]
extern crate num_derive;
extern crate num_traits;
extern crate scopeguard;
#[cfg(not(target_os = "hermit"))]
#[macro_use]
extern crate std;
......
......@@ -547,18 +547,19 @@ impl BlockedTaskQueue {
if let Some(wt) = wakeup_time {
let mut first_task = true;
let mut cursor = self.list.cursor_front_mut();
let mut _guard = scopeguard::guard(first_task, |first_task| {
// If the task is the new first task in the list, update the one-shot timer
// to fire when this task shall be woken up.
if first_task {
arch::set_oneshot_timer(wakeup_time);
}
});
while let Some(node) = cursor.current() {
let node_wakeup_time = node.wakeup_time;
if node_wakeup_time.is_none() || wt < node_wakeup_time.unwrap() {
cursor.insert_before(new_node);
// If this is the new first task in the list, update the One-Shot Timer
// to fire when this task shall be woken up.
if first_task {
arch::set_oneshot_timer(wakeup_time);
}
return;
}
......@@ -568,12 +569,6 @@ impl BlockedTaskQueue {
// No, then just insert it at the end of the list.
self.list.push_back(new_node);
// If this is the task with the ealiest deadline (=> first elemen of the list),
// update the one-shot timer to fire when this task shall be woken up.
if first_task {
arch::set_oneshot_timer(wakeup_time);
}
} else {
// No, then just insert it at the end of the list.
self.list.push_back(new_node);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment