Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
export HandleWrap Unref Ref in tcp/udp/timer/pipe
Browse files Browse the repository at this point in the history
  • Loading branch information
tjfontaine authored and piscisaureus committed Jul 23, 2012
1 parent 5bb2fe6 commit 19d43f8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/pipe_wrap.cc
Expand Up @@ -84,6 +84,7 @@ void PipeWrap::Initialize(Handle<Object> target) {

NODE_SET_PROTOTYPE_METHOD(t, "close", HandleWrap::Close);
NODE_SET_PROTOTYPE_METHOD(t, "unref", HandleWrap::Unref);
NODE_SET_PROTOTYPE_METHOD(t, "ref", HandleWrap::Ref);

NODE_SET_PROTOTYPE_METHOD(t, "readStart", StreamWrap::ReadStart);
NODE_SET_PROTOTYPE_METHOD(t, "readStop", StreamWrap::ReadStop);
Expand Down
3 changes: 3 additions & 0 deletions src/tcp_wrap.cc
Expand Up @@ -96,6 +96,9 @@ void TCPWrap::Initialize(Handle<Object> target) {

NODE_SET_PROTOTYPE_METHOD(t, "close", HandleWrap::Close);

NODE_SET_PROTOTYPE_METHOD(t, "ref", HandleWrap::Ref);
NODE_SET_PROTOTYPE_METHOD(t, "unref", HandleWrap::Unref);

NODE_SET_PROTOTYPE_METHOD(t, "readStart", StreamWrap::ReadStart);
NODE_SET_PROTOTYPE_METHOD(t, "readStop", StreamWrap::ReadStop);
NODE_SET_PROTOTYPE_METHOD(t, "shutdown", StreamWrap::Shutdown);
Expand Down
2 changes: 2 additions & 0 deletions src/timer_wrap.cc
Expand Up @@ -52,6 +52,8 @@ class TimerWrap : public HandleWrap {
constructor->SetClassName(String::NewSymbol("Timer"));

NODE_SET_PROTOTYPE_METHOD(constructor, "close", HandleWrap::Close);
NODE_SET_PROTOTYPE_METHOD(constructor, "ref", HandleWrap::Ref);
NODE_SET_PROTOTYPE_METHOD(constructor, "unref", HandleWrap::Unref);

NODE_SET_PROTOTYPE_METHOD(constructor, "start", Start);
NODE_SET_PROTOTYPE_METHOD(constructor, "stop", Stop);
Expand Down
3 changes: 3 additions & 0 deletions src/udp_wrap.cc
Expand Up @@ -110,6 +110,9 @@ void UDPWrap::Initialize(Handle<Object> target) {
NODE_SET_PROTOTYPE_METHOD(t, "setBroadcast", SetBroadcast);
NODE_SET_PROTOTYPE_METHOD(t, "setTTL", SetTTL);

NODE_SET_PROTOTYPE_METHOD(t, "ref", HandleWrap::Ref);
NODE_SET_PROTOTYPE_METHOD(t, "unref", HandleWrap::Unref);

target->Set(String::NewSymbol("UDP"),
Persistent<FunctionTemplate>::New(t)->GetFunction());
}
Expand Down

3 comments on commit 19d43f8

@AlexeyKupershtokh
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you tell in a few words what is this change for?

@tjfontaine
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case you want a timer to not hold the loop active, but fire while the loop is active

update -- the logic is valid for all handle types

@AlexeyKupershtokh
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.
I have found the following doc as well: http://nikhilm.github.com/uvbook/utilities.html#event-loop-reference-count

Please sign in to comment.