mirror of
https://github.com/librespot-org/librespot.git
synced 2025-10-03 09:49:31 +02:00
Change to parking_lot
and remove remaining panics
This commit is contained in:
parent
62461be1fc
commit
b4f7a9e35e
13 changed files with 200 additions and 121 deletions
|
@ -1,20 +1,20 @@
|
|||
macro_rules! component {
|
||||
($name:ident : $inner:ident { $($key:ident : $ty:ty = $value:expr,)* }) => {
|
||||
#[derive(Clone)]
|
||||
pub struct $name(::std::sync::Arc<($crate::session::SessionWeak, ::std::sync::Mutex<$inner>)>);
|
||||
pub struct $name(::std::sync::Arc<($crate::session::SessionWeak, ::parking_lot::Mutex<$inner>)>);
|
||||
impl $name {
|
||||
#[allow(dead_code)]
|
||||
pub(crate) fn new(session: $crate::session::SessionWeak) -> $name {
|
||||
debug!(target:"librespot::component", "new {}", stringify!($name));
|
||||
|
||||
$name(::std::sync::Arc::new((session, ::std::sync::Mutex::new($inner {
|
||||
$name(::std::sync::Arc::new((session, ::parking_lot::Mutex::new($inner {
|
||||
$($key : $value,)*
|
||||
}))))
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn lock<F: FnOnce(&mut $inner) -> R, R>(&self, f: F) -> R {
|
||||
let mut inner = (self.0).1.lock().unwrap();
|
||||
let mut inner = (self.0).1.lock();
|
||||
f(&mut inner)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue