Skip to content

Instantly share code, notes, and snippets.

@AndreasMadsen
Created January 28, 2015 20:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndreasMadsen/23050086329be2d85260 to your computer and use it in GitHub Desktop.
Save AndreasMadsen/23050086329be2d85260 to your computer and use it in GitHub Desktop.
'use strict';
var asyncWrap = process.binding('async_wrap');
var fs = require('fs');
var asyncHooksObject = {};
var kCallInitHook = 0;
asyncHooksObject[kCallInitHook] = 1;
//asyncHooksObject = new Uint8Array([1]);
//asyncHooksObject = new Buffer([1]);
asyncWrap.setupHooks(asyncHooksObject, init, before, after);
function init() {
writeSync(JSON.stringify(arguments));
writeSync('Init called');
}
function before() {
writeSync(JSON.stringify(arguments));
writeSync('Before called');
}
function after() {
writeSync(JSON.stringify(arguments));
writeSync('After called');
}
setTimeout(function () {
writeSync('Callback called');
}, 15);
function writeSync(text) {
fs.writeSync(1, text + '\n');
fs.fsyncSync(1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment