mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-17 16:44:19 +01:00
move compute to the main thread for browser and node
- now, most of the work is happening on the main thread - for database in browser, we still have dedicated WebWorker - but it is used only for OPFS access and only for that - for syn in browser we still offload sync operations to the WebWorker
This commit is contained in:
@@ -196,7 +196,12 @@ class Database {
|
||||
}
|
||||
|
||||
try {
|
||||
await this.db.batchAsync(sql);
|
||||
const stmt = this.prepare(sql);
|
||||
try {
|
||||
await stmt.run();
|
||||
} finally {
|
||||
stmt.close();
|
||||
}
|
||||
} catch (err) {
|
||||
throw convertError(err);
|
||||
}
|
||||
@@ -298,7 +303,7 @@ class Statement {
|
||||
bindParams(this.stmt, bindParameters);
|
||||
|
||||
while (true) {
|
||||
const stepResult = await this.stmt.stepAsync();
|
||||
const stepResult = this.stmt.stepSync();
|
||||
if (stepResult === STEP_IO) {
|
||||
await this.db.db.ioLoopAsync();
|
||||
continue;
|
||||
@@ -328,7 +333,7 @@ class Statement {
|
||||
bindParams(this.stmt, bindParameters);
|
||||
|
||||
while (true) {
|
||||
const stepResult = await this.stmt.stepAsync();
|
||||
const stepResult = this.stmt.stepSync();
|
||||
if (stepResult === STEP_IO) {
|
||||
await this.db.db.ioLoopAsync();
|
||||
continue;
|
||||
@@ -352,7 +357,7 @@ class Statement {
|
||||
bindParams(this.stmt, bindParameters);
|
||||
|
||||
while (true) {
|
||||
const stepResult = await this.stmt.stepAsync();
|
||||
const stepResult = this.stmt.stepSync();
|
||||
if (stepResult === STEP_IO) {
|
||||
await this.db.db.ioLoopAsync();
|
||||
continue;
|
||||
@@ -377,7 +382,7 @@ class Statement {
|
||||
const rows: any[] = [];
|
||||
|
||||
while (true) {
|
||||
const stepResult = await this.stmt.stepAsync();
|
||||
const stepResult = this.stmt.stepSync();
|
||||
if (stepResult === STEP_IO) {
|
||||
await this.db.db.ioLoopAsync();
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user