From bf52ebc1c56368334555dbfaa53a6c3d4284c323 Mon Sep 17 00:00:00 2001 From: sbosse Date: Tue, 27 Aug 2024 00:16:15 +0200 Subject: [PATCH] Tue 27 Aug 00:14:56 CEST 2024 --- test/test-forkA.js | 61 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 test/test-forkA.js diff --git a/test/test-forkA.js b/test/test-forkA.js new file mode 100644 index 0000000..c13d102 --- /dev/null +++ b/test/test-forkA.js @@ -0,0 +1,61 @@ +// Fork, migration, remote signalling +// Requires test-forkB, too. + +Aios.Sig.options.debug.send=true; + +port(DIR.IP('http://localhost:6666')) +start(); + +function ag (options) { + this.child=null; + this.master=null; + + this.act = { + init : function () { + this.master=true; + log('Starting.'); + sleep(3000); + }, + + replicate : function () { + log('Replicating...'); + this.child=fork(); + }, + + migrate : function () { + var nodes = link(DIR.IP('%')); + log('Migrating to '+nodes[0]); + if (nodes.length) moveto(DIR.NODE(nodes[0])); + }, + + killing : function () { + log('Killing child...'); + kill(this.child); + }, + + wait : function () { + log('Waiting ...'); + if (this.child) sleep(3000); else sleep(1000); + }, + + end : function () { + log('Terminating.'); + kill(); + } + } + + this.trans = { + init : replicate, + replicate : function () { return this.child?wait:migrate }, + migrate : wait, + killing : end, + wait : function () { return this.child?killing:wait }, + } + + this.next=init; + +} + +compile(ag); + +create('ag',{ },2);