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

Re: Cancellation architectural observations

From: Ron Buckton <rbuckton@chronicles.org>
Date: Mon, 2 Mar 2015 23:55:41 +0000
To: Tab Atkins Jr. <jackalmage@gmail.com>, Kevin Smith <zenparsing@gmail.com>
CC: "public-script-coord@w3.org" <public-script-coord@w3.org>, Dean Tribble <tribble@e-dean.com>, es-discuss <es-discuss@mozilla.org>
Message-ID: <1425340540395.95986@chronicles.org>
The upside of having a separate abstraction for cancellation, is that it composes well with async functions:

async function runStockTicker(receiveSymbol, cancellationToken) {
  while (!cancellationToken.canceled) {
    var symbols = await fetchSymbols(cancellationToken);
    if (!cancellationToken.canceled) {
      for (var symbol of symbols) {
      await sleep(1000);

var stopTicker = new CancellationTokenSource();
runStockTicker(..., stopTicker.token);
stopTicker.cancel(); // stop the current fetch and the loop

From: es-discuss <es-discuss-bounces@mozilla.org> on behalf of Tab Atkins Jr. <jackalmage@gmail.com>
Sent: Monday, March 02, 2015 6:21 PM
To: Kevin Smith
Cc: public-script-coord@w3.org; Dean Tribble; es-discuss
Subject: Re: Cancellation architectural observations

On Mon, Mar 2, 2015 at 3:18 PM, Kevin Smith <zenparsing@gmail.com> wrote:
> I'm afraid I don't quite understand.  How is one supposed to create a
> cancelable task with async functions, under your proposed architecture?

I'm not sure!  The mapping between promises and async functions isn't
intuitive to me yet, and I'm not sure how async functions will be able
to produce promise subclasses rather than plain promises.

es-discuss mailing list

Received on Monday, 2 March 2015 23:56:10 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:24 UTC