Advertisement
Guest User

Untitled

a guest
Jan 28th, 2015
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. 'use strict';
  2.  
  3. var asyncWrap = process.binding('async_wrap');
  4. var fs = require('fs');
  5.  
  6. var asyncHooksObject = {};
  7. var kCallInitHook = 0;
  8. asyncHooksObject[kCallInitHook] = 1;
  9.  
  10. //asyncHooksObject = new Uint8Array([1]);
  11. //asyncHooksObject = new Buffer([1]);
  12.  
  13. asyncWrap.setupHooks(asyncHooksObject, init, before, after);
  14.  
  15. function init() {
  16. writeSync(JSON.stringify(arguments));
  17. writeSync('Init called');
  18. }
  19.  
  20. function before() {
  21. writeSync(JSON.stringify(arguments));
  22. writeSync('Before called');
  23. }
  24.  
  25. function after() {
  26. writeSync(JSON.stringify(arguments));
  27. writeSync('After called');
  28. }
  29.  
  30. setTimeout(function () {
  31. writeSync('Callback called');
  32. }, 15);
  33.  
  34. function writeSync(text) {
  35. fs.writeSync(1, text + '\n');
  36. fs.fsyncSync(1);
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement