W3C home > Mailing lists > Public > public-script-coord@w3.org > January to March 2015

Re: Cancellation architectural observations

From: Kevin Smith <zenparsing@gmail.com>
Date: Tue, 3 Mar 2015 11:59:24 -0500
Message-ID: <CA+mDt2w6Sq-Y3YksFN0AQnPjkZ5morBXsRCPDHeMMhSFgXrMfQ@mail.gmail.com>
To: Ron Buckton <rbuckton@chronicles.org>
Cc: "public-script-coord@w3.org" <public-script-coord@w3.org>, es-discuss <es-discuss@mozilla.org>
> function doLater(callback, token) {
>   var handle = setImmediate(callback);
>   token.register(() => clearImmediate(handle));
> }
>
> var cts = new CancellationTokenSource();
> doLater(..., cts.token);
> cts.cancel();
>

I'm not really clear about the ordering properties of setImmediate relative
to the promise microtask queue, but:

    function doLater(callback, cancelPromise) {
        let handle;
        cancelPromise.then(_=> clearImmediate(handle));
        handle = setImmediate(callback);
    }

This should work if setImmediate uses either the same MT queue as promises
or a lower-priority queue.
Received on Tuesday, 3 March 2015 16:59:52 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 3 March 2015 16:59:54 UTC