|
|
@ -1,5 +1,5 @@ |
|
|
|
use super::core::{RegularSetupCore, SetupCore};
|
|
|
|
use super::util::{AddResult, AddableResource, InternalAddResult, Recorder};
|
|
|
|
use super::util::{AddResult, AddableResource, Recorder};
|
|
|
|
use super::SymbolRunner;
|
|
|
|
use crate::async_utils::sleep;
|
|
|
|
use crate::loggers::Logger;
|
|
|
@ -8,7 +8,7 @@ use crate::symbols::Symbol; |
|
|
|
use crate::{DefaultBuilder, DefaultLocator};
|
|
|
|
use futures_util::future::{FutureExt, Shared};
|
|
|
|
use slog::{o, trace, Logger as SlogLogger};
|
|
|
|
use std::cell::{RefCell, RefMut};
|
|
|
|
use std::cell::RefCell;
|
|
|
|
use std::collections::HashMap;
|
|
|
|
use std::error::Error;
|
|
|
|
use std::fmt::Debug;
|
|
|
@ -40,10 +40,6 @@ impl<SR, L, B, Rs, As> Setup<SR, L, B, Rs, As> { |
|
|
|
impl<L: 'static, B: 'static, SR: 'static, Rs: Hash + Eq + 'static, As: 'static>
|
|
|
|
Setup<SR, L, B, Rs, As>
|
|
|
|
{
|
|
|
|
fn borrow_resources(&self) -> RefMut<'_, Cache<Rs, As>> {
|
|
|
|
self.0.resources.borrow_mut()
|
|
|
|
}
|
|
|
|
|
|
|
|
// FIXME: https://github.com/rust-lang/rust-clippy/issues/6353
|
|
|
|
#[allow(clippy::await_holding_refcell_ref)]
|
|
|
|
pub async fn add<R: AddableResource>(
|
|
|
@ -51,15 +47,14 @@ impl<L: 'static, B: 'static, SR: 'static, Rs: Hash + Eq + 'static, As: 'static> |
|
|
|
logger: &Rc<SlogLogger>,
|
|
|
|
resource: R,
|
|
|
|
force_run: bool,
|
|
|
|
) -> InternalAddResult<R>
|
|
|
|
) -> AddResult<R>
|
|
|
|
where
|
|
|
|
Rs: FromResource<R>,
|
|
|
|
As: FromArtifact<R> + Clone,
|
|
|
|
R::Artifact: Clone,
|
|
|
|
RegularSetupCore<SR, L, B>: SetupCore<R, Self>,
|
|
|
|
{
|
|
|
|
let (storable_resource, weak_resource) = Rs::from_resource(resource);
|
|
|
|
let mut resources = self.borrow_resources();
|
|
|
|
let mut resources = self.0.resources.borrow_mut();
|
|
|
|
let result = if let Some(future) = resources.remove(&storable_resource) {
|
|
|
|
assert!(
|
|
|
|
!force_run,
|
|
|
@ -140,7 +135,6 @@ impl< |
|
|
|
where
|
|
|
|
Rs: FromResource<R>,
|
|
|
|
As: FromArtifact<R> + Clone,
|
|
|
|
R::Artifact: Clone,
|
|
|
|
RegularSetupCore<SR, L, B>: SetupCore<R, Setup<SR, L, B, Rs, As>>,
|
|
|
|
{
|
|
|
|
let recorder = Recorder::default();
|
|
|
@ -151,13 +145,13 @@ impl< |
|
|
|
self.log_result(recorder, result.as_ref().map(|(_, did_run)| *did_run));
|
|
|
|
result
|
|
|
|
}
|
|
|
|
|
|
|
|
pub async fn add<R: AddableResource>(&self, resource: R) -> AddResult<R>
|
|
|
|
where
|
|
|
|
RegularSetupCore<SR, L, B>: SetupCore<R, Setup<SR, L, B, Rs, As>>,
|
|
|
|
Rs: FromResource<R>,
|
|
|
|
As: FromArtifact<R> + Clone,
|
|
|
|
R::Artifact: Clone,
|
|
|
|
SR: SymbolRunner,
|
|
|
|
RegularSetupCore<SR, L, B>: SetupCore<R, Setup<SR, L, B, Rs, As>>,
|
|
|
|
{
|
|
|
|
self.add_force(resource, false).await
|
|
|
|
}
|
|
|
|