Skip to content

Commit de5f11c

Browse files
committed
Add back global locks and notes.
1 parent 47dc93b commit de5f11c

File tree

3 files changed

+7
-16
lines changed

3 files changed

+7
-16
lines changed

lib/src/connection_pool.dart

+4-1
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,11 @@ class SqliteConnectionPool with SqliteQueries implements SqliteConnection {
160160
return readLock((ctx) => callback(ctx as SqliteWriteContext),
161161
lockTimeout: lockTimeout, debugContext: debugContext);
162162
} else {
163+
// FIXME:
164+
// This should avoid using global locks, but then we need to fix
165+
// update notifications to only fire after commit.
163166
return _writeLock(callback,
164-
lockTimeout: lockTimeout, debugContext: debugContext, global: false);
167+
lockTimeout: lockTimeout, debugContext: debugContext, global: true);
165168
}
166169
}
167170

lib/src/sqlite_connection_impl.dart

-15
Original file line numberDiff line numberDiff line change
@@ -105,21 +105,6 @@ class SqliteConnectionImpl with SqliteQueries implements SqliteConnection {
105105
return _connectionMutex.locked;
106106
}
107107

108-
@override
109-
Future<T> lock<T>(Future<T> Function(SqliteWriteContext tx) callback,
110-
{bool? readOnly, Duration? lockTimeout, String? debugContext}) async {
111-
// Private lock to synchronize this with other statements on the same connection,
112-
// to ensure that transactions aren't interleaved.
113-
return _connectionMutex.lock(() async {
114-
final ctx = _TransactionContext(_isolateClient);
115-
try {
116-
return await callback(ctx);
117-
} finally {
118-
await ctx.close();
119-
}
120-
}, timeout: lockTimeout);
121-
}
122-
123108
@override
124109
Future<T> readLock<T>(Future<T> Function(SqliteReadContext tx) callback,
125110
{Duration? lockTimeout, String? debugContext}) async {

lib/src/sqlite_queries.dart

+3
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ mixin SqliteQueries implements SqliteWriteContext, SqliteConnection {
164164
return readTransaction((ctx) => callback(ctx as SqliteWriteContext),
165165
lockTimeout: lockTimeout);
166166
} else {
167+
// FIXME:
168+
// This should avoid using global locks, but then we need to fix
169+
// update notifications to only fire after commit.
167170
// ignore: deprecated_member_use_from_same_package
168171
return writeTransaction(callback, lockTimeout: lockTimeout);
169172
}

0 commit comments

Comments
 (0)