https://github.com/creationix/uvrun
Tiny node module to expose uv_run and uv_run_once to JavaScript
https://github.com/creationix/uvrun
Last synced: 8 months ago
JSON representation
Tiny node module to expose uv_run and uv_run_once to JavaScript
- Host: GitHub
- URL: https://github.com/creationix/uvrun
- Owner: creationix
- Created: 2013-01-01T20:58:12.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2017-04-04T03:59:36.000Z (about 9 years ago)
- Last Synced: 2024-05-02T06:10:54.187Z (about 2 years ago)
- Language: C++
- Size: 207 KB
- Stars: 19
- Watchers: 2
- Forks: 4
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# UVRun
Bindings to the uvrun functions in libuv to node.js.
Normally these functions are implicitly called by node itself.
By using runOnce, you can have finer grained control of the event loop and know when it's idle.
```js
var runOnce = require('uvrun').runOnce;
// Do something here, like make a server to keep the event loop busy
var TCP = process.binding('tcp_wrap').TCP;
var server = new TCP();
server.onconnection = function () {
console.log("connection!");
};
server.bind("0.0.0.0", 3000);
server.listen(511);
// Visualize each event loop tick using a custom event loop.
console.log("Waiting for events...");
do {
var ret = runOnce();
console.log("tick", Date.now());
} while(ret);
// If the code gets here, there are no events left and node's built-in uv_run won't block.
```