Is the answer to run the (newly added) "runTest" routine using a fibrous.run call itself?
That's part of it, yeah. Fibrous will need to call runTest
itself to be able to manage its execution.
Then, test
just needs to be wrapped rather than .run()
:
var test = fibrous(function () {
var data = fs.sync.readFile('/etc/passwd');
console.log('2');
});
And should be called with .sync()
:
test.sync();
var fibrous = require('fibrous');
var fs = require('fs');
var test = fibrous(function () {
var data = fs.sync.readFile('/etc/passwd');
console.log('2');
});
function runTest() {
console.log('1');
test.sync();
console.log('3');
}
fibrous.run(runTest);