import { AbortError } from 'abort-error';
export class JobRecipient {
    deferred;
    signal;
    constructor(signal) {
        this.signal = signal;
        this.deferred = Promise.withResolvers();
        this.onAbort = this.onAbort.bind(this);
        this.signal?.addEventListener('abort', this.onAbort);
    }
    onAbort() {
        this.deferred.reject(this.signal?.reason ?? new AbortError());
    }
    cleanup() {
        this.signal?.removeEventListener('abort', this.onAbort);
    }
}
//# sourceMappingURL=recipient.js.map