Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/powersync_core/lib/src/abort_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ class AbortController {
return _abortRequested.future;
}

Future<void> get onCompletion {
return _abortCompleter.future;
}

/// Abort, and wait until aborting is complete.
Future<void> abort() async {
aborted = true;
Expand Down
13 changes: 11 additions & 2 deletions packages/powersync_core/lib/src/database/active_instances.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,23 @@ final class ActiveDatabaseGroup {

/// Use to prevent multiple connections from being opened concurrently
final Mutex syncConnectMutex = Mutex();
final Mutex syncMutex;
final Mutex crudMutex;

final String identifier;

ActiveDatabaseGroup._(this.identifier);
ActiveDatabaseGroup._(this.identifier)
: syncMutex = Mutex(identifier: '$identifier-sync'),
crudMutex = Mutex(identifier: '$identifier-crud');

void close() {
Future<void> close() async {
if (--refCount == 0) {
final removedGroup = _activeGroups.remove(identifier);
assert(removedGroup == this);

await syncConnectMutex.close();
await syncMutex.close();
await crudMutex.close();
}
}

Expand Down
Loading