Permalink
Browse files

Revert "Use my node_async_shim.h."

This reverts commit 39f4d5d.

Conflicts:

	src/ffi.h
	src/foreign_caller.cc
  • Loading branch information...
TooTallNate committed Feb 26, 2012
1 parent 496e196 commit a213c72c2ee28d6028ad39debc953fc794a844f0
Showing with 15 additions and 51 deletions.
  1. +2 −4 src/ffi.h
  2. +13 −5 src/foreign_caller.cc
  3. +0 −42 src/node_async_shim.h
View
@@ -27,8 +27,6 @@
#define strtoull _strtoui64
#endif
-#include "node_async_shim.h"
-
#define INTEGER_CONVERSION_BUFFER_SIZE 64
#define UINT8_MIN 0
@@ -133,8 +131,8 @@ class ForeignCaller : public ObjectWrap {
protected:
static Handle<Value> New(const Arguments& args);
static Handle<Value> Exec(const Arguments& args);
- static async_rtn AsyncFFICall(uv_work_t *req);
- static async_rtn FinishAsyncFFICall(uv_work_t *req);
+ static int AsyncFFICall(eio_req *req);
+ static int FinishAsyncFFICall(eio_req *req);
ffi_cif *m_cif;
void (*m_fn)(void);
View
@@ -76,7 +76,13 @@ Handle<Value> ForeignCaller::Exec(const Arguments& args) {
// construct a new EventEmitter object
p->emitter = Persistent<Object>::New(emitterConstructor->NewInstance());
- BEGIN_ASYNC(p, ForeignCaller::AsyncFFICall, ForeignCaller::FinishAsyncFFICall);
+ ev_ref(EV_DEFAULT_UC);
+#if NODE_VERSION_AT_LEAST(0, 5, 4)
+ eio_custom((void (*)(eio_req*))ForeignCaller::AsyncFFICall, EIO_PRI_DEFAULT, ForeignCaller::FinishAsyncFFICall, p);
+#else
+ eio_custom(ForeignCaller::AsyncFFICall, EIO_PRI_DEFAULT, ForeignCaller::FinishAsyncFFICall, p);
+#endif
+
return scope.Close(p->emitter);
} else {
#if __OBJC__ || __OBJC2__
@@ -98,13 +104,15 @@ Handle<Value> ForeignCaller::Exec(const Arguments& args) {
return Undefined();
}
-async_rtn ForeignCaller::AsyncFFICall(uv_work_t *req) {
+int ForeignCaller::AsyncFFICall(eio_req *req)
+{
AsyncCallParams *p = (AsyncCallParams *)req->data;
ffi_call(p->cif, p->ptr, p->res, p->args);
- RETURN_ASYNC;
+ return 0;
}
-async_rtn ForeignCaller::FinishAsyncFFICall(uv_work_t *req) {
+int ForeignCaller::FinishAsyncFFICall(eio_req *req)
+{
HandleScope scope;
AsyncCallParams *p = (AsyncCallParams *)req->data;
@@ -131,5 +139,5 @@ async_rtn ForeignCaller::FinishAsyncFFICall(uv_work_t *req) {
FatalException(try_catch);
}
- RETURN_ASYNC_AFTER;
+ return 0;
}
View
@@ -1,42 +0,0 @@
-/**
- * eio_custom() vs. uv_queue_work() file.
- * Original gist: https://gist.github.com/1368935
- *
- * Copyright (c) 2011-2012, Nathan Rajlich <nathan@tootallnate.net>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <node.h>
-#include <node_version.h>
-
-/* Node Thread Pool version compat */
-#if NODE_VERSION_AT_LEAST(0, 5, 6)
- #define BEGIN_ASYNC(_data, async, after) \
- uv_work_t *_req = new uv_work_t; \
- _req->data = _data; \
- uv_queue_work(uv_default_loop(), _req, async, after);
- typedef void async_rtn;
- #define RETURN_ASYNC
- #define RETURN_ASYNC_AFTER delete req;
-#else
- #define BEGIN_ASYNC(data, async, after) \
- ev_ref(EV_DEFAULT_UC); \
- eio_custom(async, EIO_PRI_DEFAULT, after, data);
- typedef int async_rtn;
- typedef eio_req uv_work_t;
- #define RETURN_ASYNC return 0;
- #define RETURN_ASYNC_AFTER \
- ev_unref(EV_DEFAULT_UC); \
- RETURN_ASYNC;
-#endif

0 comments on commit a213c72

Please sign in to comment.