fix(core): update

This commit is contained in:
2020-05-27 16:06:07 +00:00
parent 4b5581a6f1
commit 912bdc61fb
9 changed files with 2372 additions and 622 deletions

View File

@ -35,6 +35,7 @@ export class Timeout<T> {
private _deferred: smartpromise.Deferred<T>;
private _timeout: any;
private _cancelled: boolean = false;
constructor(timeInMillisecondArg, passOn?: T) {
this._deferred = smartpromise.defer<T>();
this.promise = this._deferred.promise;
@ -45,11 +46,17 @@ export class Timeout<T> {
}, timeInMillisecondArg);
}
makeUnrefed() {
/**
* unreffing a timeout causes the node process to not wait for completion before exit
*/
public makeUnrefed() {
this._timeout.unref();
}
cancel() {
/**
* cancels the timer
*/
public cancel() {
this._cancelled = true;
this.makeUnrefed();
}