From 6ea3ae7b82cb4c7a7571df25bd59c24c71110440 Mon Sep 17 00:00:00 2001 From: sbosse Date: Tue, 27 Aug 2024 00:16:00 +0200 Subject: [PATCH] Tue 27 Aug 00:14:56 CEST 2024 --- test/test-jamsh2.js | 46 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 test/test-jamsh2.js diff --git a/test/test-jamsh2.js b/test/test-jamsh2.js new file mode 100644 index 0000000..46d2730 --- /dev/null +++ b/test/test-jamsh2.js @@ -0,0 +1,46 @@ +// Simple jamsh test demonstrating lifetime resource control and negotiation + +function hello() { + this.act = { + init: function () { + log('START '+privilege()); + // negotiate more lifetime (default is 2000) + log(negotiate('LIFE',10000)) + log(negotiate('SCHED',2000)) + // if negotiation was successful, we can sleep in peace, else.. + }, + compute : function () { + var start=time(); + while(true) { + if ((time()-start) > 1500) break; + }; + log('Done'); + }, + stop: function () { log('STOP'); kill() } + } + this.trans = { + init:"compute", + compute:"stop", + } + this.on = { + error: function (e,arg) { log('Error: '+e) }, + } + this.next="init" +} + +// default platform settings +config({ + IDLETIME:100, + LIFETIME:Infinity, + TIMESCHED:2000, + TIMEPOOL:10000, + RUNTIME:3000, + LEVEL:2, + verbose:3, + "log+":'time', +}) + +compile(hello,{verbose:1}) +start() + +var id=create(hello,[])