Factorize tock storage in assert_once
This commit is contained in:
12
src/env/tock/mod.rs
vendored
12
src/env/tock/mod.rs
vendored
@@ -77,18 +77,22 @@ impl Env for TockEnv {
|
||||
}
|
||||
|
||||
fn storage(&mut self) -> StorageResult<Self::Storage> {
|
||||
assert!(!self.storage);
|
||||
self.storage = true;
|
||||
assert_once(&mut self.storage);
|
||||
unsafe { steal_storage() }
|
||||
}
|
||||
|
||||
fn upgrade_storage(&mut self) -> StorageResult<Self::UpgradeStorage> {
|
||||
assert!(!self.upgrade_storage);
|
||||
self.upgrade_storage = true;
|
||||
assert_once(&mut self.upgrade_storage);
|
||||
SyscallUpgradeStorage::new()
|
||||
}
|
||||
}
|
||||
|
||||
/// Asserts a boolean is false and sets it to true.
|
||||
fn assert_once(b: &mut bool) {
|
||||
assert!(!*b);
|
||||
*b = true;
|
||||
}
|
||||
|
||||
// Returns whether the keepalive was sent, or false if cancelled.
|
||||
fn send_keepalive_up_needed(
|
||||
cid: ChannelID,
|
||||
|
||||
Reference in New Issue
Block a user