mirror of
https://github.com/erg-lang/erg.git
synced 2025-08-04 10:49:54 +00:00
Merge branch 'main' into rwlock
This commit is contained in:
parent
8c983c3714
commit
0d3691f243
143 changed files with 4781 additions and 3289 deletions
|
@ -89,13 +89,18 @@ impl<T: ?Sized> Shared<T> {
|
|||
{
|
||||
*self.borrowed_at.try_write().unwrap() = Some(std::panic::Location::caller());
|
||||
}
|
||||
self.data.try_read().unwrap_or_else(|| if cfg!(feature = "debug") {
|
||||
panic!(
|
||||
"Shared::borrow: already borrowed at {}",
|
||||
self.borrowed_at.read().as_ref().unwrap()
|
||||
)
|
||||
} else {
|
||||
panic!("Shared::borrow: already borrowed")
|
||||
self.data.try_read().unwrap_or_else(|| {
|
||||
#[cfg(feature = "debug")]
|
||||
{
|
||||
panic!(
|
||||
"Shared::borrow: already borrowed at {}",
|
||||
self.borrowed_at.read().as_ref().unwrap()
|
||||
)
|
||||
}
|
||||
#[cfg(not(feature = "debug"))]
|
||||
{
|
||||
panic!("Shared::borrow: already borrowed")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -106,13 +111,18 @@ impl<T: ?Sized> Shared<T> {
|
|||
{
|
||||
*self.borrowed_at.try_write().unwrap() = Some(std::panic::Location::caller());
|
||||
}
|
||||
self.data.try_write().unwrap_or_else(|| if cfg!(feature = "debug") {
|
||||
panic!(
|
||||
"Shared::borrow_mut: already borrowed at {}",
|
||||
self.borrowed_at.read().as_ref().unwrap()
|
||||
)
|
||||
} else {
|
||||
panic!("Shared::borrow_mut: already borrowed")
|
||||
self.data.try_write().unwrap_or_else(|| {
|
||||
#[cfg(feature = "debug")]
|
||||
{
|
||||
panic!(
|
||||
"Shared::borrow_mut: already borrowed at {}",
|
||||
self.borrowed_at.read().as_ref().unwrap()
|
||||
)
|
||||
}
|
||||
#[cfg(not(feature = "debug"))]
|
||||
{
|
||||
panic!("Shared::borrow_mut: already borrowed")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue