Skip to content

Commit

Permalink
Merge pull request #1 from ollyja/master
Browse files Browse the repository at this point in the history
migrate to uv_queue_work to work with newer version nodejs
  • Loading branch information
zhujun1980 committed Mar 12, 2014
2 parents eb9007d + 982cff1 commit 12f95ef
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions csegment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ typedef struct segment_task {
} segment_task;

Handle<Value> 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<Value> doSegmentAsync(const Arguments& args) {
HandleScope scope;
Expand All @@ -42,13 +42,15 @@ Handle<Value> doSegmentAsync(const Arguments& args) {
memset(task, 0, sizeof(segment_task) + content.length() + 1);
task->cb = Persistent<Function>::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);

Expand All @@ -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<Value> argv[1];
Expand All @@ -83,7 +84,6 @@ static int doSegmentAfter(eio_req *req) {
free(task->rst);
free(task);
}
return 0;
}

extern "C" {
Expand Down

0 comments on commit 12f95ef

Please # to comment.