mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-10-31 14:49:24 +00:00
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