|
@@ -19,12 +19,18 @@ const
|
|
ThreadCount = 4;
|
|
ThreadCount = 4;
|
|
|
|
|
|
Type
|
|
Type
|
|
-
|
|
|
|
|
|
+ // Need to unify this host class with the WasiThreadedApp one...
|
|
|
|
+
|
|
{ TWASIThreadControllerHost }
|
|
{ TWASIThreadControllerHost }
|
|
|
|
|
|
TWASIThreadControllerHost = class(TWASIHost)
|
|
TWASIThreadControllerHost = class(TWASIHost)
|
|
Protected
|
|
Protected
|
|
class function NeedSharedMemory: Boolean; override;
|
|
class function NeedSharedMemory: Boolean; override;
|
|
|
|
+ function GetThreadSupport: TThreadController; virtual;
|
|
|
|
+ Procedure DoAfterInstantiate; override;
|
|
|
|
+ Function CreateWasiEnvironment : TPas2JSWASIEnvironment; override;
|
|
|
|
+ Public
|
|
|
|
+ Property ThreadSupport : TThreadController Read GetThreadSupport;
|
|
end;
|
|
end;
|
|
|
|
|
|
{ TWorkerThreadControllerApplication }
|
|
{ TWorkerThreadControllerApplication }
|
|
@@ -54,6 +60,24 @@ begin
|
|
Result:=True;
|
|
Result:=True;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function TWASIThreadControllerHost.GetThreadSupport: TThreadController;
|
|
|
|
+begin
|
|
|
|
+ Result:=TThreadController.Instance as TThreadController;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+procedure TWASIThreadControllerHost.DoAfterInstantiate;
|
|
|
|
+begin
|
|
|
|
+ inherited DoAfterInstantiate;
|
|
|
|
+ If Assigned(ThreadSupport) then
|
|
|
|
+ // Will send load commands
|
|
|
|
+ ThreadSupport.SetWasmModuleAndMemory(PreparedStartDescriptor.Module,PreparedStartDescriptor.Memory);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TWASIThreadControllerHost.CreateWasiEnvironment: TPas2JSWASIEnvironment;
|
|
|
|
+begin
|
|
|
|
+ Result:=inherited CreateWasiEnvironment;
|
|
|
|
+end;
|
|
|
|
+
|
|
{ TWorkerThreadControllerApplication }
|
|
{ TWorkerThreadControllerApplication }
|
|
|
|
|
|
procedure TWorkerThreadControllerApplication.HandleRawExecuteCommand(aCommand : TCustomWorkerCommand);
|
|
procedure TWorkerThreadControllerApplication.HandleRawExecuteCommand(aCommand : TCustomWorkerCommand);
|
|
@@ -141,11 +165,11 @@ var
|
|
begin
|
|
begin
|
|
inherited create(aOwner);
|
|
inherited create(aOwner);
|
|
FThreadSupport:=TWasmThreadSupportApi.Create(WasiEnvironment);
|
|
FThreadSupport:=TWasmThreadSupportApi.Create(WasiEnvironment);
|
|
- RegisterMessageHandlers;
|
|
|
|
lWorker:=GetEnvironmentVar('worker');
|
|
lWorker:=GetEnvironmentVar('worker');
|
|
if lWorker='' then
|
|
if lWorker='' then
|
|
lWorker:='worker';
|
|
lWorker:='worker';
|
|
TCommandDispatcher.Instance.DefaultSenderID:=lWorker;
|
|
TCommandDispatcher.Instance.DefaultSenderID:=lWorker;
|
|
|
|
+ globalThreadController.AllocateInitialworkers;
|
|
end;
|
|
end;
|
|
|
|
|
|
destructor TWorkerThreadControllerApplication.destroy;
|
|
destructor TWorkerThreadControllerApplication.destroy;
|