File tree Expand file tree Collapse file tree 5 files changed +20
-0
lines changed Expand file tree Collapse file tree 5 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ class DarwinBinding extends BaseBinding {
47
47
. then ( ( ) => {
48
48
const fd = this . fd ;
49
49
this . poller . stop ( ) ;
50
+ this . poller . destroy ( ) ;
50
51
this . poller = null ;
51
52
this . openOptions = null ;
52
53
this . fd = null ;
Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ class LinuxBinding extends BaseBinding {
47
47
. then ( ( ) => {
48
48
const fd = this . fd ;
49
49
this . poller . stop ( ) ;
50
+ this . poller . destroy ( ) ;
50
51
this . poller = null ;
51
52
this . openOptions = null ;
52
53
this . fd = null ;
Original file line number Diff line number Diff line change @@ -89,6 +89,16 @@ class Poller extends EventEmitter {
89
89
stop ( ) {
90
90
logger ( 'Stopping poller' ) ;
91
91
this . poller . stop ( ) ;
92
+ this . emitCanceled ( ) ;
93
+ }
94
+
95
+ destroy ( ) {
96
+ logger ( 'Destroying poller' ) ;
97
+ this . poller . destroy ( ) ;
98
+ this . emitCanceled ( ) ;
99
+ }
100
+
101
+ emitCanceled ( ) {
92
102
const err = new Error ( 'Canceled' ) ;
93
103
err . canceled = true ;
94
104
this . emit ( 'readable' , err ) ;
Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ NAN_MODULE_INIT(Poller::Init) {
76
76
77
77
Nan::SetPrototypeMethod (tpl, " poll" , poll);
78
78
Nan::SetPrototypeMethod (tpl, " stop" , stop);
79
+ Nan::SetPrototypeMethod (tpl, " destroy" , destroy);
79
80
80
81
constructor ().Reset (Nan::GetFunction (tpl).ToLocalChecked ());
81
82
Nan::Set (target, Nan::New (" Poller" ).ToLocalChecked (), Nan::GetFunction (tpl).ToLocalChecked ());
@@ -122,6 +123,12 @@ NAN_METHOD(Poller::stop) {
122
123
obj->stop ();
123
124
}
124
125
126
+ NAN_METHOD (Poller::destroy) {
127
+ Poller* obj = Nan::ObjectWrap::Unwrap<Poller>(info.Holder ());
128
+ obj->persistent ().Reset ();
129
+ delete obj;
130
+ }
131
+
125
132
inline Nan::Persistent<v8::Function> & Poller::constructor () {
126
133
static Nan::Persistent<v8::Function> my_constructor;
127
134
return my_constructor;
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ class Poller : public Nan::ObjectWrap {
26
26
static NAN_METHOD (New);
27
27
static NAN_METHOD (poll);
28
28
static NAN_METHOD (stop);
29
+ static NAN_METHOD (destroy);
29
30
static inline Nan::Persistent<v8::Function> & constructor ();
30
31
};
31
32
You can’t perform that action at this time.
0 commit comments