From 80293fc5889ddce2a7b37bacdb982859ceca9e31 Mon Sep 17 00:00:00 2001 From: Michael Van Canneyt Date: Mon, 25 Nov 2024 21:30:07 +0100 Subject: [PATCH] * Allow to override thread support for worker thread app --- packages/wasi/src/wasiworkerthreadhost.pas | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/wasi/src/wasiworkerthreadhost.pas b/packages/wasi/src/wasiworkerthreadhost.pas index 4001a92..45e8315 100644 --- a/packages/wasi/src/wasiworkerthreadhost.pas +++ b/packages/wasi/src/wasiworkerthreadhost.pas @@ -166,6 +166,7 @@ Type procedure HandleConsoleWrite(Sender: TObject; aOutput: string); function HandleCustomCommand(aData: TWorkerCommand): Boolean; virtual; function CreateHost: TWASIHost; override; + function CreateWorkerThreadSupport(aEnv: TPas2JSWasiEnvironment): TWorkerThreadSupport; virtual; procedure HandleMessage(aEvent: TJSEvent); override; procedure ShowException(aError: Exception); override; // Our thread support object @@ -713,6 +714,12 @@ begin ConsoleChannel.postMessage(TWorkerConsoleCommand.Create(aOutput)); end; +function TWorkerThreadRunnerApplication.CreateWorkerThreadSupport(aEnv : TPas2JSWasiEnvironment) : TWorkerThreadSupport; + +begin + Result:=TWorkerThreadSupport.Create(aEnv); +end; + function TWorkerThreadRunnerApplication.CreateHost: TWASIHost; var @@ -721,7 +728,8 @@ var begin TH:=TWASIThreadHost.Create(Self); TH.OnConsoleWrite:=@HandleConsoleWrite; - FThreadSupport:=TWorkerThreadSupport.Create(TH.WasiEnvironment); + FThreadSupport:=CreateWorkerThreadSupport(TH.WasiEnvironment); + FThreadSupport.OnSendCommand:=@DoOnSendCommand; TH.ThreadSupport:=FThreadSupport; // Sets FThreadSupport.host Result:=TH;