@@ -8,9 +8,11 @@ import 'package:sqlite_async/src/sqlite_queries.dart';
88import 'package:sqlite_async/src/update_notification.dart' ;
99import 'package:sqlite_async/src/utils/profiler.dart' ;
1010
11+ import '../../impl/context.dart' ;
12+
1113/// A simple "synchronous" connection which provides the async SqliteConnection
1214/// implementation using a synchronous SQLite connection
13- class SyncSqliteConnection extends SqliteConnection with SqliteQueries {
15+ class SyncSqliteConnection with SqliteQueries implements SqliteConnection {
1416 final CommonDatabase db;
1517 late Mutex mutex;
1618 @override
@@ -44,7 +46,10 @@ class SyncSqliteConnection extends SqliteConnection with SqliteQueries {
4446 return mutex.lock (
4547 () {
4648 task? .finish ();
47- return callback (SyncReadContext (db, parent: task));
49+ return ScopedReadContext .assumeReadLock (
50+ _UnsafeSyncContext (db, parent: task),
51+ callback,
52+ );
4853 },
4954 timeout: lockTimeout,
5055 );
@@ -59,7 +64,10 @@ class SyncSqliteConnection extends SqliteConnection with SqliteQueries {
5964 return mutex.lock (
6065 () {
6166 task? .finish ();
62- return callback (SyncWriteContext (db, parent: task));
67+ return ScopedWriteContext .assumeWriteLock (
68+ _UnsafeSyncContext (db, parent: task),
69+ callback,
70+ );
6371 },
6472 timeout: lockTimeout,
6573 );
@@ -80,12 +88,12 @@ class SyncSqliteConnection extends SqliteConnection with SqliteQueries {
8088 }
8189}
8290
83- class SyncReadContext implements SqliteReadContext {
91+ final class _UnsafeSyncContext extends UnscopedContext {
8492 final TimelineTask ? task;
8593
8694 CommonDatabase db;
8795
88- SyncReadContext (this .db, {TimelineTask ? parent})
96+ _UnsafeSyncContext (this .db, {TimelineTask ? parent})
8997 : task = TimelineTask (parent: parent);
9098
9199 @override
@@ -129,10 +137,6 @@ class SyncReadContext implements SqliteReadContext {
129137 Future <bool > getAutoCommit () async {
130138 return db.autocommit;
131139 }
132- }
133-
134- class SyncWriteContext extends SyncReadContext implements SqliteWriteContext {
135- SyncWriteContext (super .db, {super .parent});
136140
137141 @override
138142 Future <ResultSet > execute (String sql,
0 commit comments