@@ -13,6 +13,30 @@ import {
1313
1414import type { SqliteDialectConfig } from "./sqlite-dialect-config.ts" ;
1515
16+ class ConnectionMutex {
17+ #promise?: Promise < void > ;
18+ #resolve?: ( ) => void ;
19+
20+ async lock ( ) : Promise < void > {
21+ while ( this . #promise) {
22+ await this . #promise;
23+ }
24+
25+ this . #promise = new Promise ( resolve => {
26+ this . #resolve = resolve ;
27+ } ) ;
28+ }
29+
30+ unlock ( ) : void {
31+ const resolve = this . #resolve;
32+
33+ this . #promise = undefined ;
34+ this . #resolve = undefined ;
35+
36+ resolve ?.( ) ;
37+ }
38+ }
39+
1640export class SqliteDriver implements Driver {
1741 readonly #config: SqliteDialectConfig ;
1842 readonly #connectionMutex = new ConnectionMutex ( ) ;
@@ -144,30 +168,6 @@ class SqliteConnection implements DatabaseConnection {
144168 }
145169}
146170
147- class ConnectionMutex {
148- #promise?: Promise < void > ;
149- #resolve?: ( ) => void ;
150-
151- async lock ( ) : Promise < void > {
152- while ( this . #promise) {
153- await this . #promise;
154- }
155-
156- this . #promise = new Promise ( resolve => {
157- this . #resolve = resolve ;
158- } ) ;
159- }
160-
161- unlock ( ) : void {
162- const resolve = this . #resolve;
163-
164- this . #promise = undefined ;
165- this . #resolve = undefined ;
166-
167- resolve ?.( ) ;
168- }
169- }
170-
171171function parseSavepointCommand ( command : string , savepointName : string ) : RawNode {
172172 return RawNode . createWithChildren ( [
173173 RawNode . createWithSql ( `${ command } ` ) ,
0 commit comments