mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-04-05 13:37:47 +02:00
* Conditional logging
This commit is contained in:
parent
22746ebdc3
commit
755e5ffc1e
@ -4,6 +4,7 @@ unit wasiworkerthreadhost;
|
|||||||
|
|
||||||
{$mode ObjFPC}
|
{$mode ObjFPC}
|
||||||
{$modeswitch externalclass}
|
{$modeswitch externalclass}
|
||||||
|
{ $define NOLOGAPICALLS}
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
@ -453,12 +454,16 @@ procedure TWorkerThreadSupport.RunWasmModule(aCommand : TWorkerRunCommand);
|
|||||||
begin
|
begin
|
||||||
if (FState=wsNeutral) then
|
if (FState=wsNeutral) then
|
||||||
begin
|
begin
|
||||||
Writeln('No webassembly loaded');
|
{$IFNDEF NOLOGAPICALLS}
|
||||||
|
DoLog('No webassembly loaded');
|
||||||
|
{$ENDIF}
|
||||||
exit; // Todo: send error back
|
exit; // Todo: send error back
|
||||||
end;
|
end;
|
||||||
if (FState in [wsRunning,wsRunWaiting]) then
|
if (FState in [wsRunning,wsRunWaiting]) then
|
||||||
begin
|
begin
|
||||||
Writeln('Webassembly already running');
|
{$IFNDEF NOLOGAPICALLS}
|
||||||
|
DoLog('Webassembly already running');
|
||||||
|
{$ENDIF}
|
||||||
exit; // Todo: send error back
|
exit; // Todo: send error back
|
||||||
end;
|
end;
|
||||||
// Writeln('Entering TWorkerThreadSupport.RunWasmModule '+TJSJSON.Stringify(aCommand));
|
// Writeln('Entering TWorkerThreadSupport.RunWasmModule '+TJSJSON.Stringify(aCommand));
|
||||||
@ -763,9 +768,15 @@ Var
|
|||||||
aData : TWorkerCommand;
|
aData : TWorkerCommand;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
{$IFNDEF NOLOGAPICALLS}
|
||||||
|
DoLog(etDebug,'Message received in worker');
|
||||||
|
{$ENDIF}
|
||||||
if IsObject(aMessageEvent.Data) and TJSObject(aMessageEvent.Data).hasOwnProperty('Command') then
|
if IsObject(aMessageEvent.Data) and TJSObject(aMessageEvent.Data).hasOwnProperty('Command') then
|
||||||
begin
|
begin
|
||||||
aData:=TWorkerCommand(aMessageEvent.Data);
|
aData:=TWorkerCommand(aMessageEvent.Data);
|
||||||
|
{$IFNDEF NOLOGAPICALLS}
|
||||||
|
DoLog(etDebug,'Command Message received in worker: '+TJSJSON.Stringify(aData));
|
||||||
|
{$ENDIF}
|
||||||
if not HandleCustomCommand(aData) then
|
if not HandleCustomCommand(aData) then
|
||||||
FThreadSupport.HandleCommand(aData);
|
FThreadSupport.HandleCommand(aData);
|
||||||
end
|
end
|
||||||
@ -899,9 +910,11 @@ var
|
|||||||
aData: TWorkerCommand;
|
aData: TWorkerCommand;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
Writeln('Thread Message received');
|
||||||
if IsObject(aMessageEvent.Data) and TJSObject(aMessageEvent.Data).hasOwnProperty('Command') then
|
if IsObject(aMessageEvent.Data) and TJSObject(aMessageEvent.Data).hasOwnProperty('Command') then
|
||||||
begin
|
begin
|
||||||
aData:=TWorkerCommand(aMessageEvent.Data);
|
aData:=TWorkerCommand(aMessageEvent.Data);
|
||||||
|
Writeln('Command message received: '+TJSJSON.Stringify(aData));
|
||||||
case aData.Command of
|
case aData.Command of
|
||||||
cmdExecute : HandleExecuteCommand(TWorkerExecuteCommand(aData));
|
cmdExecute : HandleExecuteCommand(TWorkerExecuteCommand(aData));
|
||||||
cmdRpc : HandleRPCCommand(TWorkerRpcCommand(aData));
|
cmdRpc : HandleRPCCommand(TWorkerRpcCommand(aData));
|
||||||
|
Loading…
Reference in New Issue
Block a user