From 982cff157614299ccf4483437c6f95081369faec Mon Sep 17 00:00:00 2001 From: chunlei Date: Wed, 12 Mar 2014 00:05:04 -0400 Subject: [PATCH] migrate to uv_queue_work to work with newer version nodejs --- csegment.cc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/csegment.cc b/csegment.cc index 13dfb72..c9dd093 100644 --- a/csegment.cc +++ b/csegment.cc @@ -16,8 +16,8 @@ typedef struct segment_task { } segment_task; Handle doSegmentAsync(const Arguments& args); -static void doSegment(eio_req *req); -static int doSegmentAfter(eio_req *req); +static void doSegment(uv_work_t *req); +static void doSegmentAfter(uv_work_t *req, int status); Handle doSegmentAsync(const Arguments& args) { HandleScope scope; @@ -42,13 +42,15 @@ Handle doSegmentAsync(const Arguments& args) { memset(task, 0, sizeof(segment_task) + content.length() + 1); task->cb = Persistent::New(cb); strncpy(task->content, *content, content.length()); - - eio_custom(doSegment, EIO_PRI_DEFAULT, doSegmentAfter, task); - ev_ref(EV_DEFAULT_UC); + + uv_work_t *req = new uv_work_t; + req->data = task; + + uv_queue_work(uv_default_loop(), req, doSegment, doSegmentAfter); return Undefined(); } -static void doSegment(eio_req *req) { +static void doSegment(uv_work_t *req) { segment_task *task = (segment_task *)req->data; unsigned int nLen = strlen(task->content); @@ -62,10 +64,9 @@ static void doSegment(eio_req *req) { //ICTCLAS_Exit(); } -static int doSegmentAfter(eio_req *req) { +static void doSegmentAfter(uv_work_t *req, int status) { HandleScope scope; - ev_unref(EV_DEFAULT_UC); segment_task *task = (segment_task *)req->data; Local argv[1]; @@ -83,7 +84,6 @@ static int doSegmentAfter(eio_req *req) { free(task->rst); free(task); } - return 0; } extern "C" {