mirror of
https://github.com/Zenithsiz/zbuild.git
synced 2026-02-04 06:28:57 +00:00
Replaced Builder::build_results with into_build_results.
It's technically slower because it's got to lock everything, but at this point there should be no other locks (which our old solution relied on), so locking should be pretty fast.
This commit is contained in:
parent
5390fb8019
commit
fcf3c77971
@ -95,11 +95,13 @@ impl Builder {
|
||||
}
|
||||
|
||||
/// Returns all build results
|
||||
pub fn into_build_results(self) -> IndexMap<ArcStr, Option<Result<BuildResult, ()>>> {
|
||||
pub async fn build_results(&self) -> IndexMap<ArcStr, Option<Result<BuildResult, ()>>> {
|
||||
self.rules_lock
|
||||
.into_iter()
|
||||
.map(|(rule, lock)| (rule.name, lock.into_res()))
|
||||
.iter()
|
||||
.map(async move |rule_lock| (rule_lock.key().name.clone(), rule_lock.value().res().await))
|
||||
.collect::<FuturesUnordered<_>>()
|
||||
.collect()
|
||||
.await
|
||||
}
|
||||
|
||||
/// Sends an event, if any are subscribers
|
||||
|
||||
@ -52,13 +52,9 @@ impl BuildLock {
|
||||
}
|
||||
}
|
||||
|
||||
/// Retrieves this lock's result by consuming the lock
|
||||
pub fn into_res(self) -> Option<Result<BuildResult, ()>> {
|
||||
// TODO: Not panic here
|
||||
Arc::try_unwrap(self.state)
|
||||
.expect("Leftover references when unwrapping build lock")
|
||||
.into_inner()
|
||||
.res
|
||||
/// Retrieves this lock's result
|
||||
pub async fn res(&self) -> Option<Result<BuildResult, ()>> {
|
||||
self.state.read().await.res
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -187,7 +187,7 @@ async fn main() -> ExitResult {
|
||||
);
|
||||
|
||||
// Finally print some statistics
|
||||
let targets = builder.into_build_results();
|
||||
let targets = builder.build_results().await;
|
||||
let total_targets = targets.len();
|
||||
let built_targets = targets
|
||||
.iter()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user