From bc80d7991d357f7c94d382be5bff91dfb18c63a5 Mon Sep 17 00:00:00 2001 From: Steve Terlecki Date: Mon, 19 Mar 2012 14:19:21 -0400 Subject: [PATCH 1/2] Updating signature of EIO_Hello to support changes to eio_custom in libeio in latest versions of node.js --- helloworld_eio/helloworld_eio.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/helloworld_eio/helloworld_eio.cc b/helloworld_eio/helloworld_eio.cc index 3943439..48a38c7 100644 --- a/helloworld_eio/helloworld_eio.cc +++ b/helloworld_eio/helloworld_eio.cc @@ -87,15 +87,13 @@ class HelloWorldEio: ObjectWrap } - static int EIO_Hello(eio_req *req) + static void EIO_Hello(eio_req *req) { hello_baton_t *baton = static_cast(req->data); sleep(baton->sleep_for); baton->hw->m_count += baton->increment_by; - - return 0; } static int EIO_AfterHello(eio_req *req) From 604f94a774eeabb3c3d7e0ac1cd63d20a492c429 Mon Sep 17 00:00:00 2001 From: Steve Terlecki Date: Mon, 19 Mar 2012 15:43:51 -0400 Subject: [PATCH 2/2] Adding test js files to illustrate the example --- .gitignore | 2 ++ helloworld/test.js | 3 +++ helloworld_eio/test.js | 8 ++++++++ 3 files changed, 13 insertions(+) create mode 100644 .gitignore create mode 100644 helloworld/test.js create mode 100644 helloworld_eio/test.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..34a9dbd --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +build +.lock* diff --git a/helloworld/test.js b/helloworld/test.js new file mode 100644 index 0000000..4040caa --- /dev/null +++ b/helloworld/test.js @@ -0,0 +1,3 @@ +var helloWorld = require('./build/Release/helloworld'); +var world = new helloWorld.HelloWorld(); +console.log(world.hello()); diff --git a/helloworld_eio/test.js b/helloworld_eio/test.js new file mode 100644 index 0000000..48648d1 --- /dev/null +++ b/helloworld_eio/test.js @@ -0,0 +1,8 @@ +var helloeio = require('./build/Release/helloworld_eio'); +var hi = new helloeio.HelloWorldEio(); +hi.hello(function(data){ + console.log(data); +}); +//Outputting something here to show that the callback is non-blocking and this +//output will be displayed before the Hello World message. +console.log('Outputted after the async call to hello world.');