Skip to content

Commit

Permalink
GH-195: Made Resolve able to resolve tasks sync
Browse files Browse the repository at this point in the history
  • Loading branch information
CMDJojo committed Mar 30, 2023
1 parent 8f04984 commit 7963bf1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
1 change: 1 addition & 0 deletions core/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ where
lock.expose_transforms(config.try_into()?)?;
Ok(true)
} else {
drop(lock);
self.resolver.resolve_all(missings);
Ok(false)
}
Expand Down
3 changes: 1 addition & 2 deletions core/src/package_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,7 @@ impl From<Hide> for PackageID {
}

pub trait Resolve {
/// The implementor should resolve the given tasks in an **asynchronous manner**. It is of
/// highest importance that this is isn't done synchronous, since that would give a dead-lock.
/// The implementor should resolve the given ResolveTasks, and may do so sync or async
fn resolve_all(&self, paths: Vec<ResolveTask>);
}

Expand Down
11 changes: 2 additions & 9 deletions playground/web_bindings/src/web_resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,7 @@ pub fn resolve(task: ResolveTask) {
let target = task.package.source.clone();
match target {
PackageSource::Local => {
// Note that these "simple rejects" must be called in async since otherwise we would
// get recursive mutex locks, and that isn't implemented in Wasm
spawn_local(async move {
task.reject(WebResolveError::NotImplemented);
});
task.reject(WebResolveError::NotImplemented);
}
PackageSource::Registry => {
spawn_local(async move {
Expand All @@ -70,10 +66,7 @@ pub fn resolve(task: ResolveTask) {
});
}
PackageSource::Standard => {
// See note for PackageSource::Local
spawn_local(async move {
task.reject(WebResolveError::NotImplemented);
});
task.reject(WebResolveError::NotImplemented);
}
}
}
Expand Down

0 comments on commit 7963bf1

Please sign in to comment.