@@ -8,6 +8,7 @@ import 'package:stream_channel/stream_channel.dart';
88import 'package:web/web.dart'
99 hide Response, Request, FileSystem, Notification, Lock;
1010
11+ import 'locks.dart' ;
1112import 'types.dart' ;
1213import 'channel.dart' ;
1314import 'database.dart' ;
@@ -329,7 +330,7 @@ final class DatabaseClient implements WebSqlite {
329330 final DatabaseController _localController;
330331 final Future <JSAny ?> Function (JSAny ? ) _handleCustomRequest;
331332
332- final Lock _startWorkersLock = Lock ();
333+ final Mutex _startWorkers = Mutex ();
333334 bool _startedWorkers = false ;
334335 WorkerConnection ? _connectionToDedicated;
335336 WorkerConnection ? _connectionToShared;
@@ -347,7 +348,7 @@ final class DatabaseClient implements WebSqlite {
347348 });
348349
349350 Future <void > startWorkers () {
350- return _startWorkersLock. synchronized (() async {
351+ return _startWorkers. withCriticalSection (() async {
351352 if (_startedWorkers) {
352353 return ;
353354 }
@@ -406,7 +407,7 @@ final class DatabaseClient implements WebSqlite {
406407 }
407408
408409 Future <WorkerConnection > _connectToDedicatedInShared () {
409- return _startWorkersLock. synchronized (() async {
410+ return _startWorkers. withCriticalSection (() async {
410411 if (_connectionToDedicatedInShared case final conn? ) {
411412 return conn;
412413 }
@@ -421,7 +422,7 @@ final class DatabaseClient implements WebSqlite {
421422 }
422423
423424 Future <WorkerConnection > _connectToLocal () async {
424- return _startWorkersLock. synchronized (() async {
425+ return _startWorkers. withCriticalSection (() async {
425426 if (_connectionToLocal case final conn? ) {
426427 return conn;
427428 }
0 commit comments