mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-25 19:45:05 +08:00
add some warning
This commit is contained in:
parent
0749633618
commit
c1fcb2ebc6
@ -27,13 +27,17 @@ pub trait RefCellExt<T: ?Sized> {
|
|||||||
|
|
||||||
impl<T: ?Sized> RefCellExt<T> for RefCell<T> {
|
impl<T: ?Sized> RefCellExt<T> for RefCell<T> {
|
||||||
fn try_borrow_or_yield(&self) -> std::result::Result<Ref<'_, T>, std::cell::BorrowError> {
|
fn try_borrow_or_yield(&self) -> std::result::Result<Ref<'_, T>, std::cell::BorrowError> {
|
||||||
|
/// TODO: move this trait and impl elsewhere
|
||||||
loop {
|
loop {
|
||||||
match self.try_borrow() {
|
match self.try_borrow() {
|
||||||
Ok(borrow) => break Ok(borrow),
|
Ok(borrow) => break Ok(borrow),
|
||||||
Err(error) => match rayon::yield_local() {
|
Err(error) => {
|
||||||
|
tracing::warn!("dynamic borrow failed, yielding to local tasks");
|
||||||
|
match rayon::yield_local() {
|
||||||
Some(rayon::Yield::Executed) => continue,
|
Some(rayon::Yield::Executed) => continue,
|
||||||
_ => return Err(error),
|
_ => return Err(error),
|
||||||
},
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -44,10 +48,14 @@ impl<T: ?Sized> RefCellExt<T> for RefCell<T> {
|
|||||||
loop {
|
loop {
|
||||||
match self.try_borrow_mut() {
|
match self.try_borrow_mut() {
|
||||||
Ok(borrow) => break Ok(borrow),
|
Ok(borrow) => break Ok(borrow),
|
||||||
Err(error) => match rayon::yield_local() {
|
Err(error) => {
|
||||||
|
tracing::warn!("dynamic borrow failed, yielding to local tasks");
|
||||||
|
|
||||||
|
match rayon::yield_local() {
|
||||||
Some(rayon::Yield::Executed) => continue,
|
Some(rayon::Yield::Executed) => continue,
|
||||||
_ => return Err(error),
|
_ => return Err(error),
|
||||||
},
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -168,6 +176,7 @@ impl<T: MostlySend> ThreadLocal<T> {
|
|||||||
where
|
where
|
||||||
F: FnOnce() -> T,
|
F: FnOnce() -> T,
|
||||||
{
|
{
|
||||||
|
/// TODO: move ThreadLocal, MostlySend, FullySend to a dedicated file
|
||||||
self.inner.get_or(|| unsafe { MostlySendWrapper::new(create()) }).as_ref()
|
self.inner.get_or(|| unsafe { MostlySendWrapper::new(create()) }).as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user