Skip to content

Commit

Permalink
Use uv_work_t to bring Windows back.
Browse files Browse the repository at this point in the history
  • Loading branch information
TooTallNate committed Feb 26, 2012
1 parent a213c72 commit adbc7f1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/ffi.h
Expand Up @@ -131,8 +131,8 @@ class ForeignCaller : public ObjectWrap {
protected:
static Handle<Value> New(const Arguments& args);
static Handle<Value> Exec(const Arguments& args);
static int AsyncFFICall(eio_req *req);
static int FinishAsyncFFICall(eio_req *req);
static void AsyncFFICall(uv_work_t *req);
static void FinishAsyncFFICall(uv_work_t *req);

ffi_cif *m_cif;
void (*m_fn)(void);
Expand Down
19 changes: 6 additions & 13 deletions src/foreign_caller.cc
Expand Up @@ -76,12 +76,9 @@ Handle<Value> ForeignCaller::Exec(const Arguments& args) {
// construct a new EventEmitter object
p->emitter = Persistent<Object>::New(emitterConstructor->NewInstance());

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
uv_work_t *req = new uv_work_t;
req->data = p;
uv_queue_work(uv_default_loop(), req, ForeignCaller::AsyncFFICall, ForeignCaller::FinishAsyncFFICall);

return scope.Close(p->emitter);
} else {
Expand All @@ -104,15 +101,12 @@ Handle<Value> ForeignCaller::Exec(const Arguments& args) {
return Undefined();
}

int ForeignCaller::AsyncFFICall(eio_req *req)
{
void ForeignCaller::AsyncFFICall(uv_work_t *req) {
AsyncCallParams *p = (AsyncCallParams *)req->data;
ffi_call(p->cif, p->ptr, p->res, p->args);
return 0;
}

int ForeignCaller::FinishAsyncFFICall(eio_req *req)
{
void ForeignCaller::FinishAsyncFFICall(uv_work_t *req) {
HandleScope scope;

AsyncCallParams *p = (AsyncCallParams *)req->data;
Expand All @@ -134,10 +128,9 @@ int ForeignCaller::FinishAsyncFFICall(eio_req *req)

// free up our memory (allocated in FFICall)
delete p;
delete req;

if (try_catch.HasCaught()) {
FatalException(try_catch);
}

return 0;
}

0 comments on commit adbc7f1

Please sign in to comment.