Re: [whatwg/dom] Abort controller design (#438)

AbortSignal gains an associated **incoming port** (a MessagePort object) and **outgoing ports** (a set of MessagePort objects).

AbortSignal object serialization steps:

1. If _value_'s aborted flag is set, then set _serialized_.[[Aborted]] to true and return. (Or should we simply throw? There's not much point to this.)
1. Let _channel_ be a new MessageChannel object.
1. Append _channel_'s port1 to _value_'s outgoing ports.
1. Append the following algorithm to _value_'s abort algorithms: (Aside: we should change abort algorithms invocation to pass a _signal_ argument.)
    1. For each _port_ in _signal_'s outgoing ports: invoke _port_'s `postMessage()` with "aborted". (Aside: hopefully we can do better than this.)
1. Set _serialized_.[[IncomingPort]] to ! StructuredSerializeWithTransfer(_channel_'s port2, _channel_'s port2).

AbortSignal object deserialization steps:

1. If _serialized_.[[Aborted]] is present and true, then set _value_'s aborted flag and return.
1. Set _value_'s incoming port to ! StructuredDeserializeWithTransfer(_serialized_.[[IncomingPort]], the current Realm).
1. Append an event listener to _value_'s incoming port listening for "message" events that runs these steps with the event _e_:
   1. Assert: _e_.data is "aborted".
   1. Run signal abort with _value_.
1. Enable _value_'s incoming port.

I think this works, but it needs to be double checked.

cc @domenic 

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/438#issuecomment-301476670

Received on Monday, 15 May 2017 13:37:22 UTC