FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix libuv threading issue by johnhaley81 · Pull Request #435 · nodegit/nodegit · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .cc  (2) .h  (2) .js  (1) All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
18 changes: 7 additions & 11 deletions generate/templates/partials/callback_helpers.cc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
baton->req.data = baton;
baton->done = false;

uv_queue_work(uv_default_loop(), &baton->req, {{ cppFunctionName }}_{{ cbFunction.name }}_asyncWork, {{ cppFunctionName }}_{{ cbFunction.name }}_asyncAfter);
uv_async_init(uv_default_loop(), &baton->req, {{ cppFunctionName }}_{{ cbFunction.name }}_async);
uv_async_send(&baton->req);

while(!baton->done) {
this_thread::sleep_for(chrono::milliseconds(1));
Expand All @@ -31,13 +32,7 @@
return baton->result;
}

void {{ cppClassName }}::{{ cppFunctionName }}_{{ cbFunction.name }}_asyncWork(uv_work_t* req) {
// We aren't doing any work on a seperate thread, just need to
// access the main node thread in the async after method.
// However, this worker method is still needed
}

void {{ cppClassName }}::{{ cppFunctionName }}_{{ cbFunction.name }}_asyncAfter(uv_work_t* req, int status) {
void {{ cppClassName }}::{{ cppFunctionName }}_{{ cbFunction.name }}_async(uv_async_t* req, int status) {
NanScope();

{{ cppFunctionName }}_{{ cbFunction.name|titleCase }}Baton* baton = static_cast<{{ cppFunctionName }}_{{ cbFunction.name|titleCase }}Baton*>(req->data);
Expand Down Expand Up @@ -85,7 +80,8 @@ void {{ cppClassName }}::{{ cppFunctionName }}_{{ cbFunction.name }}_asyncAfter(

NanAssignPersistent(baton->promise, promise);

uv_queue_work(uv_default_loop(), &baton->req, {{ cppFunctionName }}_{{ cbFunction.name }}_asyncWork, {{ cppFunctionName }}_{{ cbFunction.name }}_asyncPromisePolling);
uv_async_init(uv_default_loop(), &baton->req, {{ cppFunctionName }}_{{ cbFunction.name }}_asyncPromisePolling);
uv_async_send(&baton->req);
return;
}
}
Expand Down Expand Up @@ -117,7 +113,7 @@ void {{ cppClassName }}::{{ cppFunctionName }}_{{ cbFunction.name }}_asyncAfter(
baton->done = true;
}

void {{ cppClassName }}::{{ cppFunctionName }}_{{ cbFunction.name }}_asyncPromisePolling(uv_work_t* req, int status) {
void {{ cppClassName }}::{{ cppFunctionName }}_{{ cbFunction.name }}_asyncPromisePolling(uv_async_t* req, int status) {
NanScope();

{{ cppFunctionName }}_{{ cbFunction.name|titleCase }}Baton* baton = static_cast<{{ cppFunctionName }}_{{ cbFunction.name|titleCase }}Baton*>(req->data);
Expand All @@ -127,7 +123,7 @@ void {{ cppClassName }}::{{ cppFunctionName }}_{{ cbFunction.name }}_asyncPromis
Local<Boolean> isPending = isPendingFn->Call(0, argv)->ToBoolean();

if (isPending->Value()) {
uv_queue_work(uv_default_loop(), &baton->req, {{ cppFunctionName }}_{{ cbFunction.name }}_asyncWork, {{ cppFunctionName }}_{{ cbFunction.name }}_asyncPromisePolling);
uv_async_send(&baton->req);
return;
}

Expand Down
18 changes: 7 additions & 11 deletions generate/templates/partials/field_accessors.cc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@
baton->req.data = baton;
baton->done = false;

uv_queue_work(uv_default_loop(), &baton->req, {{ field.name }}_asyncWork, {{ field.name }}_asyncAfter);
uv_async_init(uv_default_loop(), &baton->req, {{ field.name }}_async);
uv_async_send(&baton->req);

while(!baton->done) {
this_thread::sleep_for(chrono::milliseconds(1));
Expand All @@ -111,13 +112,7 @@
return baton->result;
}

void {{ cppClassName }}::{{ field.name }}_asyncWork(uv_work_t* req) {
// We aren't doing any work on a seperate thread, just need to
// access the main node thread in the async after method.
// However, this worker method is still needed
}

void {{ cppClassName }}::{{ field.name }}_asyncAfter(uv_work_t* req, int status) {
void {{ cppClassName }}::{{ field.name }}_async(uv_async_t* req, int status) {
NanScope();

{{ field.name|titleCase }}Baton* baton = static_cast<{{ field.name|titleCase }}Baton*>(req->data);
Expand Down Expand Up @@ -178,7 +173,8 @@

NanAssignPersistent(baton->promise, promise);

uv_queue_work(uv_default_loop(), &baton->req, {{ field.name }}_asyncWork, {{ field.name }}_asyncPromisePolling);
uv_async_init(uv_default_loop(), &baton->req, {{ field.name }}_asyncPromisePolling);
uv_async_send(&baton->req);
return;
}
}
Expand Down Expand Up @@ -210,7 +206,7 @@
baton->done = true;
}

void {{ cppClassName }}::{{ field.name }}_asyncPromisePolling(uv_work_t* req, int status) {
void {{ cppClassName }}::{{ field.name }}_asyncPromisePolling(uv_async_t* req, int status) {
NanScope();

{{ field.name|titleCase }}Baton* baton = static_cast<{{ field.name|titleCase }}Baton*>(req->data);
Expand All @@ -220,7 +216,7 @@
Local<Boolean> isPending = isPendingFn->Call(0, argv)->ToBoolean();

if (isPending->Value()) {
uv_queue_work(uv_default_loop(), &baton->req, {{ field.name }}_asyncWork, {{ field.name }}_asyncPromisePolling);
uv_async_send(&baton->req);
return;
}

Expand Down
7 changes: 3 additions & 4 deletions generate/templates/templates/class_header.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,14 @@ class {{ cppClassName }} : public ObjectWrap {
{% endeach %}
);

static void {{ function.cppFunctionName }}_{{ arg.name }}_asyncWork(uv_work_t* req);
static void {{ function.cppFunctionName }}_{{ arg.name }}_asyncAfter(uv_work_t* req, int status);
static void {{ function.cppFunctionName }}_{{ arg.name }}_asyncPromisePolling(uv_work_t* req, int status);
static void {{ function.cppFunctionName }}_{{ arg.name }}_async(uv_async_t* req, int status);
static void {{ function.cppFunctionName }}_{{ arg.name }}_asyncPromisePolling(uv_async_t* req, int status);
struct {{ function.cppFunctionName }}_{{ arg.name|titleCase }}Baton {
{% each arg.args|argsInfo as cbArg %}
{{ cbArg.cType }} {{ cbArg.name }};
{% endeach %}

uv_work_t req;
uv_async_t req;
{{ arg.return.type }} result;
Persistent<Object> promise;
bool done;
Expand Down
7 changes: 3 additions & 4 deletions generate/templates/templates/struct_header.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,14 @@ class {{ cppClassName }} : public ObjectWrap {
{% endeach %}
);

static void {{ field.name }}_asyncWork(uv_work_t* req);
static void {{ field.name }}_asyncAfter(uv_work_t* req, int status);
static void {{ field.name }}_asyncPromisePolling(uv_work_t* req, int status);
static void {{ field.name }}_async(uv_async_t* req, int status);
static void {{ field.name }}_asyncPromisePolling(uv_async_t* req, int status);
struct {{ field.name|titleCase }}Baton {
{% each field.args|argsInfo as arg %}
{{ arg.cType }} {{ arg.name}};
{% endeach %}

uv_work_t req;
uv_async_t req;
{{ field.return.type }} result;
Persistent<Object> promise;
bool done;
Expand Down
2 changes: 1 addition & 1 deletion test/tests/remote.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ describe("Remote", function() {
});
});

it.skip("can monitor transfer progress while downloading", function() {
it("can monitor transfer progress while downloading", function() {
// Set a reasonable timeout here now that our repository has grown.
this.timeout(600000);

Expand Down

Back | FazBrowse Home | New Git URL