Allen Wirfs-Brock (2014-06-23T21:16:45.000Z)
It seems to me that the best way to do this in ES6 would be to run the call backs as individual Jobs (what until recently we were calling ES Tasks, http://people.mozilla.org/~jorendorff/es6-draft.html#sec-tasks-and-task-queues ).  The mechanisms are already in the ES6 spec. so that any any unhanded exceptions that occur in a Job are handled in the common implementation defined manner.

What would have to be defined would be a new ES API for adding the invocation of a ES function as a pending job in a job queue.  Maybe something like:

Function.prototype.callAsJob = function(...args) {
    $$EnqueueJob("UserJobs", ScriptEvaluationJob, args);  //handwave for calling ES internal abstraction operation
}

then notifyListners could just be:

 for (listener of listeners) {
   listener.callAsJob();
 }

and all the event handlers would be enqueue before any of them actually ran, which I believe is closer to what we want in terms of the ES concurrency model. 

Of course, an ES level Jobs API could include other embellishments such as explicitly setting an unhandled exception handler for a Job, or associating completion of a Job with a Promise.

Allen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140623/1a6449ea/attachment.html>
dignifiedquire at gmail.com (2014-06-23T21:23:21.472Z)
It seems to me that the best way to do this in ES6 would be to run the call backs as individual Jobs (what until recently we were calling ES Tasks, http://people.mozilla.org/~jorendorff/es6-draft.html#sec-tasks-and-task-queues ).  The mechanisms are already in the ES6 spec. so that any any unhanded exceptions that occur in a Job are handled in the common implementation defined manner.

What would have to be defined would be a new ES API for adding the invocation of a ES function as a pending job in a job queue.  Maybe something like:

```js
Function.prototype.callAsJob = function(...args) {
  $$EnqueueJob("UserJobs", ScriptEvaluationJob, args);  //handwave for calling ES internal abstraction operation
}
```
then notifyListners could just be:
```js
for (listener of listeners) {
  listener.callAsJob();
}
```
and all the event handlers would be enqueue before any of them actually ran, which I believe is closer to what we want in terms of the ES concurrency model. 

Of course, an ES level Jobs API could include other embellishments such as explicitly setting an unhandled exception handler for a Job, or associating completion of a Job with a Promise.