Skip to content

Commit

Permalink
fix deadlock
Browse files Browse the repository at this point in the history
  • Loading branch information
jakemac53 committed Aug 28, 2023
1 parent 16a94aa commit 2152d09
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions build_resolvers/lib/src/resolver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,21 @@ class PerActionResolver implements ReleasableResolver {
// We only want transitively resolved ids in `_entrypoints`.
if (transitive) _entryPoints.add(id);

// Performing a resolve is a "write" - it will result in `changeFile`
// calls in the analysis driver.
await _readAndWritePool.withResource(() =>
// The resolver will only visit assets that haven't been resolved
// in this step yet.
_step.trackStage(
'Resolving library $id',
() => _delegate._uriResolver.performResolve(
_step,
[id],
(withDriver) => _driverPool
.withResource(() => withDriver(_delegate._driver)),
transitive: transitive)));
// The resolver will only visit assets that haven't been resolved
// in this step yet.
await _step.trackStage(
'Resolving library $id',
() => _delegate._uriResolver.performResolve(
_step,
[id],
// This does a "write" - it will result in
// `changeFile` calls in the analysis driver.
// TODO: Better abstraction here? We are relying on
// implementation details (knowing this calls changeFile).
(withDriver) => _readAndWritePool.withResource(() =>
_driverPool
.withResource(() => withDriver(_delegate._driver))),
transitive: transitive));
}
});

Expand Down Expand Up @@ -238,6 +240,7 @@ class AnalyzerResolver implements ReleasableResolver {
Future<LibraryElement> libraryFor(AssetId assetId,
{bool allowSyntaxErrors = false}) async {
// TODO: Are we sure this can't deadlock?
// Since this calls `getLibraryByUri` it is a "read".
final library = await _readAndWritePool
.withResource(() => _driverPool.withResource(() async {
var uri = assetId.uri;
Expand Down

0 comments on commit 2152d09

Please sign in to comment.