1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Minor cleanups in the opfs-sahpool pause/unpause API demo.

FossilOrigin-Name: e205cdc468e02eefdeb8d391d921aa2d4d28a8b7b87036d6d937a9928261a413
This commit is contained in:
stephan
2025-01-31 17:47:47 +00:00
parent a75321d735
commit cee7609074
4 changed files with 29 additions and 18 deletions

View File

@ -335,8 +335,8 @@ sqlite3Worker1Promiser.v2 = function(config){
/** /**
When built as a module, we export sqlite3Worker1Promiser.v2() When built as a module, we export sqlite3Worker1Promiser.v2()
instead of sqlite3Worker1Promise() because (A) its interface is more instead of sqlite3Worker1Promise() because (A) its interface is more
conventional for ESM usage and (B) the ESM option export option for conventional for ESM usage and (B) the ESM export option for this
this API did not exist until v2 was created, so there's no backwards API did not exist until v2 was created, so there's no backwards
incompatibility. incompatibility.
*/ */
export default sqlite3Worker1Promiser.v2; export default sqlite3Worker1Promiser.v2;

View File

@ -12,9 +12,12 @@
These tests are specific to the opfs-sahpool VFS and are limited to These tests are specific to the opfs-sahpool VFS and are limited to
demonstrating its pause/unpause capabilities. demonstrating its pause/unpause capabilities.
Most of this file is infrastructure for displaying results to the
user. Search for runTests() to find where the work actually starts.
*/ */
'use strict'; 'use strict';
(function(self){ (function(){
let logClass; let logClass;
const mapToString = (v)=>{ const mapToString = (v)=>{
@ -35,7 +38,6 @@
return JSON.stringify(v,undefined,2); return JSON.stringify(v,undefined,2);
}; };
const normalizeArgs = (args)=>args.map(mapToString); const normalizeArgs = (args)=>args.map(mapToString);
console.log("Running in the UI thread.");
const logTarget = document.querySelector('#test-output'); const logTarget = document.querySelector('#test-output');
logClass = function(cssClass,...args){ logClass = function(cssClass,...args){
const ln = document.createElement('div'); const ln = document.createElement('div');
@ -78,8 +80,6 @@
throw new Error(args.join(' ')); throw new Error(args.join(' '));
}; };
const nextHandlerQueue = [];
const endOfWork = (passed=true)=>{ const endOfWork = (passed=true)=>{
const eH = document.querySelector('#color-target'); const eH = document.querySelector('#color-target');
const eT = document.querySelector('title'); const eT = document.querySelector('title');
@ -95,6 +95,8 @@
} }
}; };
const nextHandlerQueue = [];
const nextHandler = function(workerId,...msg){ const nextHandler = function(workerId,...msg){
log(workerId,...msg); log(workerId,...msg);
(nextHandlerQueue.shift())(); (nextHandlerQueue.shift())();
@ -105,7 +107,16 @@
W.postMessage({type:msgType}); W.postMessage({type:msgType});
}; };
const runTriangleOfDeath = function(W1, W2){ /**
Run a series of operations on an sahpool db spanning two workers.
This would arguably be more legible with Promises, but creating a
Promise-based communication channel for this purpose is left as
an exercise for the reader. An example of such a proxy can be
found in the SQLite source tree:
https://sqlite.org/src/file/ext/wasm/api/sqlite3-worker1-promiser.c-pp.js
*/
const runPyramidOfDoom = function(W1, W2){
postThen(W1, 'vfs-acquire', function(){ postThen(W1, 'vfs-acquire', function(){
postThen(W1, 'db-init', function(){ postThen(W1, 'db-init', function(){
postThen(W1, 'db-query', function(){ postThen(W1, 'db-query', function(){
@ -122,7 +133,7 @@
}; };
const runTests = function(){ const runTests = function(){
log("Running sahpool pausing tests..."); log("Running opfs-sahpool pausing tests...");
const wjs = 'sahpool-worker.js?sqlite3.dir=../../../jswasm'; const wjs = 'sahpool-worker.js?sqlite3.dir=../../../jswasm';
const W1 = new Worker(wjs+'&workerId=w1'), const W1 = new Worker(wjs+'&workerId=w1'),
W2 = new Worker(wjs+'&workerId=w2'); W2 = new Worker(wjs+'&workerId=w2');
@ -160,7 +171,7 @@
case 'initialized': case 'initialized':
log(data.workerId, ': Worker initialized',...data.payload); log(data.workerId, ': Worker initialized',...data.payload);
if( 2===++initCount ){ if( 2===++initCount ){
runTriangleOfDeath(W1, W2); runPyramidOfDoom(W1, W2);
} }
break; break;
} }
@ -169,4 +180,4 @@
}; };
runTests(); runTests();
})(globalThis); })();

View File

@ -1,5 +1,5 @@
C Add\sthe\sconventional\slicense\sheader\sto\ssahpool-worker.js\sand\scorrect\sthe\sdate\son\sthe\sheader\sin\ssahpool-pausing.js. C Minor\scleanups\sin\sthe\sopfs-sahpool\spause/unpause\sAPI\sdemo.
D 2025-01-31T16:34:52.960 D 2025-01-31T17:47:47.173
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d
@ -649,7 +649,7 @@ F ext/wasm/api/sqlite3-vfs-opfs-sahpool.c-pp.js 4878cf2a19577093ea82b505f0b05214
F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 9b86ca2d8276cf919fbc9ba2a10e9786033b64f92c2db844d951804dee6c4b4e F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 9b86ca2d8276cf919fbc9ba2a10e9786033b64f92c2db844d951804dee6c4b4e
F ext/wasm/api/sqlite3-vtab-helper.c-pp.js e809739d71e8b35dfe1b55d24d91f02d04239e6aef7ca1ea92a15a29e704f616 F ext/wasm/api/sqlite3-vtab-helper.c-pp.js e809739d71e8b35dfe1b55d24d91f02d04239e6aef7ca1ea92a15a29e704f616
F ext/wasm/api/sqlite3-wasm.c 83f5e9f998e9fa4261eb84e9f092210e3ffe03895119f5ded0429eb34ab9d2be F ext/wasm/api/sqlite3-wasm.c 83f5e9f998e9fa4261eb84e9f092210e3ffe03895119f5ded0429eb34ab9d2be
F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js 46f303ba8ddd1b2f0a391798837beddfa72e8c897038c8047eda49ce7d5ed46b F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js bc65debfe43b81fc39fb25c40ad0cc1946bd82580fbf644351107b544d6177ee
F ext/wasm/api/sqlite3-worker1.c-pp.js 5e8706c2c4af2a57fbcdc02f4e7ef79869971bc21bb8ede777687786ce1c92d5 F ext/wasm/api/sqlite3-worker1.c-pp.js 5e8706c2c4af2a57fbcdc02f4e7ef79869971bc21bb8ede777687786ce1c92d5
F ext/wasm/batch-runner-sahpool.html e9a38fdeb36a13eac7b50241dfe7ae066fe3f51f5c0b0151e7baee5fce0d07a7 F ext/wasm/batch-runner-sahpool.html e9a38fdeb36a13eac7b50241dfe7ae066fe3f51f5c0b0151e7baee5fce0d07a7
F ext/wasm/batch-runner-sahpool.js 54a3ac228e6c4703fe72fb65c897e19156263a51fe9b7e21d2834a45e876aabd F ext/wasm/batch-runner-sahpool.js 54a3ac228e6c4703fe72fb65c897e19156263a51fe9b7e21d2834a45e876aabd
@ -701,7 +701,7 @@ F ext/wasm/tests/opfs/concurrency/index.html 657578a6e9ce1e9b8be951549ed93a6a471
F ext/wasm/tests/opfs/concurrency/test.js d08889a5bb6e61937d0b8cbb78c9efbefbf65ad09f510589c779b7cc6a803a88 F ext/wasm/tests/opfs/concurrency/test.js d08889a5bb6e61937d0b8cbb78c9efbefbf65ad09f510589c779b7cc6a803a88
F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2 F ext/wasm/tests/opfs/concurrency/worker.js 0a8c1a3e6ebb38aabbee24f122693f1fb29d599948915c76906681bb7da1d3d2
F ext/wasm/tests/opfs/sahpool/index.html be736567fd92d3ecb9754c145755037cbbd2bca01385e2732294b53f4c842328 F ext/wasm/tests/opfs/sahpool/index.html be736567fd92d3ecb9754c145755037cbbd2bca01385e2732294b53f4c842328
F ext/wasm/tests/opfs/sahpool/sahpool-pausing.js 780952b64dcde74ced1bb74813c0f995b689130f93d0a589995c78a783ec88ac F ext/wasm/tests/opfs/sahpool/sahpool-pausing.js f264925cfc82155de38cecb3d204c36e0f6991460fff0cb7c15079454679a4e2
F ext/wasm/tests/opfs/sahpool/sahpool-worker.js bd25a43fc2ab2d1bafd8f2854ad3943ef673f7c3be03e95ecf1612ff6e8e2a61 F ext/wasm/tests/opfs/sahpool/sahpool-worker.js bd25a43fc2ab2d1bafd8f2854ad3943ef673f7c3be03e95ecf1612ff6e8e2a61
F ext/wasm/wasmfs.make 68999f5bd8c489239592d59a420f8c627c99169bbd6fa16a404751f757b9f702 F ext/wasm/wasmfs.make 68999f5bd8c489239592d59a420f8c627c99169bbd6fa16a404751f757b9f702
F magic.txt 5ade0bc977aa135e79e3faaea894d5671b26107cc91e70783aa7dc83f22f3ba0 F magic.txt 5ade0bc977aa135e79e3faaea894d5671b26107cc91e70783aa7dc83f22f3ba0
@ -2212,8 +2212,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350
F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P 09570c55a23e5af76dd2153a5b28a493f498d7d4a08b0089f3074d0a2c5d3d29 P f7c3026b0d2e33cc4e3b906810d860b155b1ff714bbe4e1eb9ee392122217efa
R bfbe4fbf82db0e350871f46cfbfa28ef R d3225c8561b09d79116dc329da2feefd
U stephan U stephan
Z d959934b83791a6e7fb628c4c0368bb3 Z 1cb85d7c9b9ce473d92184ec221c275c
# Remove this line to create a well-formed Fossil manifest. # Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
f7c3026b0d2e33cc4e3b906810d860b155b1ff714bbe4e1eb9ee392122217efa e205cdc468e02eefdeb8d391d921aa2d4d28a8b7b87036d6d937a9928261a413