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