mirror of
https://github.com/m-labs/artiq.git
synced 2024-12-19 00:16:29 +08:00
Rust: use try_borrow where applicable.
This commit is contained in:
parent
30e997f045
commit
398b709e25
@ -1,5 +1,5 @@
|
|||||||
#![no_std]
|
#![no_std]
|
||||||
#![feature(libc, borrow_state, const_fn)]
|
#![feature(libc, borrow_state, const_fn, try_borrow)]
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate std_artiq as std;
|
extern crate std_artiq as std;
|
||||||
|
@ -68,17 +68,16 @@ impl ThreadHandle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn terminated(&self) -> bool {
|
pub fn terminated(&self) -> bool {
|
||||||
match self.0.borrow_state() {
|
match self.0.try_borrow() {
|
||||||
BorrowState::Unused => self.0.borrow().terminated(),
|
Ok(thread) => thread.terminated(),
|
||||||
_ => false // the running thread hasn't terminated
|
Err(_) => false // the running thread hasn't terminated
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn interrupt(&self) {
|
pub fn interrupt(&self) {
|
||||||
// FIXME: use try_borrow() instead once it's available
|
match self.0.try_borrow_mut() {
|
||||||
match self.0.borrow_state() {
|
Ok(mut thread) => thread.interrupt(),
|
||||||
BorrowState::Unused => self.0.borrow_mut().interrupt(),
|
Err(_) => panic!("cannot interrupt the running thread")
|
||||||
_ => panic!("cannot interrupt the running thread")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user