mirror of
https://github.com/polserver/polserver
synced 2026-08-13 08:23:08 -04:00
* test for sending a function to the same program * store executor pid inside funcrefs and classes * docs
31 lines
605 B
Text
31 lines
605 B
Text
use os;
|
|
|
|
var state;
|
|
|
|
program prog( args )
|
|
state := args[2];
|
|
var parent := GetProcess( args[1] );
|
|
if ( state == "main" )
|
|
return spawn();
|
|
else
|
|
parent.SendEvent( struct{ res := @() { return state; } } );
|
|
Wait_For_Event( 1 );
|
|
endif
|
|
endprogram
|
|
|
|
function spawn()
|
|
var spawned := start_script( ":testfuncref:send_same_prog", { GetPid(), "secondary" } );
|
|
|
|
if ( !spawned )
|
|
return $"failed to spawn: {spawned}";
|
|
endif
|
|
|
|
var ev := Wait_For_Event( 1 );
|
|
if ( !ev )
|
|
return $"no event: {ev}";
|
|
endif
|
|
var res := ev.res.call();
|
|
spawned.SendEvent( 1 );
|
|
return res;
|
|
endfunction
|
|
|