Jump to content

Structured concurrency

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Lucenty (talk | contribs) at 02:53, 12 October 2019 (cancellation handling is fundamental to structured concurrency (errors should always propagate up to the parent)). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Structured concurrency is a programming paradigm aimed at improving the clarity, quality, and development time of a computer program by using a structured approach to concurrent programming. The core concept is that when control splits into concurrent tasks that they join up again, that subtask errors cause children and siblings to be cancelled before propagating to the parent, and that this control flow is readily evident by the structure of the source code. If a "main task" splits into several concurrent sub-tasks then those sub-tasks must terminate before the main task can complete. To be effective, this model must be applied consistently throughout the program-- otherwise concurrent tasks may leak out, become orphaned, or fail to have runtime errors correctly propagated.

The naming is inspired by structured programming, which created higher level control-flow statements out of the very basic goto. Similarly, structured concurrency creates higher level mechanisms for concurrency constructs out of the basic concurrent task creation constructs (spawn, threads, fibers).

The concept was formulated in 2016 by Martin Sústrik (creator of ZeroMQ)[1], and then further refined in 2018 by Nathaniel J. Smith, who implemented it in Trio.[2] Meanwhile, Roman Elizarov independently came upon the same ideas while developing an experimental coroutine library for the Kotlin language.[3][4]

See also

References

Citations

  1. ^ Sústrik, Martin (7 February 2016). "Structured Concurrency". Retrieved 1 August 2019.
  2. ^ Smith, Nathaniel J. (25 April 2018). "Notes on structured concurrency, or: Go statement considered harmful". Retrieved 1 August 2019.
  3. ^ Elizarov, Roman (12 September 2018). "Structured concurrency". Retrieved 21 September 2019.
  4. ^ Elizarov, Roman (July 2019). Structured concurrency (Videotape). Hydra Distributed computing conference. 42 minutes in. Retrieved 21 September 2019. We needed a name and we needed to finalize this whole concept [...] and we stumble onto this blog post [...] by Nathaniel J. Smith.