About generators

Jason Orendorff jason.orendorff at gmail.com
Thu May 14 14:47:37 UTC 2015


On Thu, May 14, 2015 at 2:05 AM,  <Mohan.Radhakrishnan at cognizant.com> wrote:
> Thanks. What is the underlying concurrency framework when we use generators
> for concurrent workloads ? Does it depend on the particular VM ?

Generators aren't for concurrency.

When a generator runs, it runs in the same thread as the caller. The
order of execution is sequential and deterministic, and never
concurrent. Unlike system threads, a generator is only ever suspended
at points marked by yield in its body.

(copied from <https://hacks.mozilla.org/2015/05/es6-in-depth-generators/>)

-j


More information about the es-discuss mailing list