Tue 27 Aug 00:14:56 CEST 2024
This commit is contained in:
parent
c3edce729d
commit
6ea3ae7b82
46
test/test-jamsh2.js
Normal file
46
test/test-jamsh2.js
Normal file
|
@ -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,[])
|
Loading…
Reference in New Issue
Block a user