1
0
Fork 0
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:
Roderick van Domburg 2021-12-26 22:55:45 +01:00
parent 62461be1fc
commit b4f7a9e35e
No known key found for this signature in database
GPG key ID: A9EF5222A26F0451
13 changed files with 200 additions and 121 deletions

View file

@ -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)
}