forked from mirrors/gstreamer-rs
Add into_inner() / try_into_inner() functions for SendCell
This commit is contained in:
parent
5676aeb3ef
commit
43a014b6fa
1 changed files with 13 additions and 0 deletions
|
@ -143,6 +143,19 @@ impl<T> SendCell<T> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn into_inner(self) -> T {
|
||||
assert_eq!(thread::current().id(), self.thread_id);
|
||||
self.data
|
||||
}
|
||||
|
||||
pub fn try_into_inner(self) -> Result<T, Self> {
|
||||
if thread::current().id() == self.thread_id {
|
||||
Ok(self.data)
|
||||
} else {
|
||||
Err(self)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get(&self) -> &T {
|
||||
assert_eq!(thread::current().id(), self.thread_id);
|
||||
&self.data
|
||||
|
|
Loading…
Reference in a new issue