Created
January 28, 2015 20:49
-
-
Save AndreasMadsen/23050086329be2d85260 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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