W3C home > Mailing lists > Public > public-script-coord@w3.org > April to June 2013

Re: Future cancellation

From: Jonas Sicking <jonas@sicking.cc>
Date: Tue, 30 Apr 2013 19:47:21 -0700
Message-ID: <CA+c2ei9z8n-wRkcvnGV=E=05wmgmmwDr-D-7qDVZex2aBRJngw@mail.gmail.com>
To: Bjoern Hoehrmann <derhoermi@gmx.net>
Cc: es-discuss <es-discuss@mozilla.org>, "public-script-coord@w3.org" <public-script-coord@w3.org>
On Tue, Apr 30, 2013 at 5:56 PM, Bjoern Hoehrmann <derhoermi@gmx.net> wrote:
> * Jonas Sicking wrote:
>>I do not think that we should add cancellation on the base Future
>>interface. I.e. we shouldn't make *all* Futures cancellable.
>>
>>Cancelability should only be possible when the implementation of the
>>Future would actually stop doing work if the Future is cancelled. I.e.
>>cancelling a Future shouldn't simply prevent the result callbacks from
>>being called, but it should prevent whatever work is needed to
>>calculate the result from happening.
>>
>>However it would be very complex and expensive if we had to make all
>>APIs that want to use Futures also support being cancelled.
>
> You seem to be arguing based on the word "cancel". The semantic would
> rather be "Please note that I am no longer interested in this value",
> which would make sense even if the "work" is not actually "stopped",
> and, accordingly, it would not be complex and expensive to support.
>
> In other words, I think most people would agree that a "forced stop"
> option for everything is complex and expensive and should not be re-
> quired, but that does not necessarily invalidate the ideas that moti-
> vate a "cancel" option.

"I am no longer interested in receiving this value" is definitely a
separation operation than "I want the operation to be stopped".

If you're no longer interested in receiving a particular value, that
may or may not mean that others are interested in that value. Futures
support multiple callers registering to be told about a particular
result. And, as importantly, they support people registering to
receive a result at any point in time.

If we want to support the semantics of "I am no longer interested in
receiving this value" then I propose that we add a way to "unregister"
an individual .then() callback. But I'm not at all sure that this is a
use case that is important enough to implement. Callers can always
ignore the value once it comes in.

/ Jonas
Received on Wednesday, 1 May 2013 02:48:19 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:37:49 UTC