Browse Source

handle_wrap: replace unref_ field with flags_ field

Prep work for a follow-up commit that adds support for close callbacks.
v0.9.12-release
Ben Noordhuis 12 years ago
parent
commit
3d20905b70
  1. 6
      src/handle_wrap.cc
  2. 4
      src/handle_wrap.h
  3. 2
      src/node.cc

6
src/handle_wrap.cc

@ -63,7 +63,7 @@ Handle<Value> HandleWrap::Ref(const Arguments& args) {
if (wrap) {
uv_ref(wrap->handle__);
wrap->unref_ = false;
wrap->flags_ &= ~kUnref;
}
return v8::Undefined();
@ -77,7 +77,7 @@ Handle<Value> HandleWrap::Unref(const Arguments& args) {
if (wrap) {
uv_unref(wrap->handle__);
wrap->unref_ = true;
wrap->flags_ |= kUnref;
}
return v8::Undefined();
@ -102,7 +102,7 @@ Handle<Value> HandleWrap::Close(const Arguments& args) {
HandleWrap::HandleWrap(Handle<Object> object, uv_handle_t* h) {
unref_ = false;
flags_ = 0;
handle__ = h;
if (h) {
h->data = this;

4
src/handle_wrap.h

@ -70,7 +70,9 @@ class HandleWrap {
// Using double underscore due to handle_ member in tcp_wrap. Probably
// tcp_wrap should rename it's member to 'handle'.
uv_handle_t* handle__;
bool unref_;
unsigned int flags_;
static const unsigned int kUnref = 1;
};

2
src/node.cc

@ -1382,7 +1382,7 @@ Handle<Value> GetActiveHandles(const Arguments& args) {
ngx_queue_foreach(q, &handle_wrap_queue) {
HandleWrap* w = container_of(q, HandleWrap, handle_wrap_queue_);
if (w->object_.IsEmpty() || w->unref_) continue;
if (w->object_.IsEmpty() || (w->flags_ & HandleWrap::kUnref)) continue;
Local<Value> obj = w->object_->Get(owner_sym);
if (obj->IsUndefined()) obj = *w->object_;
ary->Set(i++, obj);

Loading…
Cancel
Save