Skip to content
Search

Coroutine

lastmod 2018-10-13created 2015-10-134 edits

Coroutines are computer program components that generalize subroutines for nonpreemptive multitasking, by allowing multiple entry points for suspending and resuming execution at certain locations. Coroutines are well-suited for implementing more familiar program components such as cooperative tasks, exceptions, event loop, iterators, infinite lists and pipes.

What is a Coroutine

The set of code that forms the core of a program and is made to be called when the program runs is called the Main Routine, and all Routines other than the Main Routine are called Subroutines. A Subroutine that can have multiple entry points is called a Coroutine. Because a Coroutine can call the Routine that called it as an equal, it is sometimes described as not being subordinate to other Routines.

In C++, the main function can be seen as the Main Routine and all other functions as Subroutines. So a Coroutine can be described as something that can, from within a function, call back the caller, and whose midpoint can in turn be called again from another Routine.

Project

  • libcopp - cross-platform coroutine library in c++

See also

Favorite site

References


  1. Gamedevforever.com_-_Cpp_Coroutine.pdf ↩

author Zer0 sitemap