Knowledge

Coroutine

Source πŸ“

511:, as in both cases the control changes to a different one of a set of routines. However, coroutines are more flexible and generally more efficient. Since coroutines yield rather than return, and then resume execution rather than restarting from the beginning, they are able to hold state, both variables (as in a closure) and execution point, and yields are not limited to being in tail position; mutually recursive subroutines must either use shared variables or pass state as parameters. Further, each mutually recursive call of a subroutine requires a new stack frame (unless 245:
coroutines, which may later return to the point where they were invoked in the original coroutine; from the coroutine's point of view, it is not exiting but calling another coroutine. Thus, a coroutine instance holds state, and varies between invocations; there can be multiple instances of a given coroutine at once. The difference between calling another coroutine by means of
919:, often boolean flags) to maintain an internal state between calls, and to transfer control to the correct point. Conditionals within the code result in the execution of different code paths on successive calls, based on the values of the state variables. Another typical response is to implement an explicit state machine in the form of a large and complex 36: 2120:"All of this makes generator functions quite similar to coroutines; they yield multiple times, they have more than one entry point and their execution can be suspended. The only difference is that a generator function cannot control where should the execution continue after it yields; the control is always transferred to the generator's caller." 1479:(CLR) hosting APIs to handle fiber-based scheduling with an eye towards its use in fiber-mode for SQL server. Before release, support for the task switching hook ICLRTask::SwitchOut was removed due to time constraints. Consequently, the use of the fiber API to switch tasks is currently not a viable option in the .NET Framework. 260:
Here is a simple example of how coroutines can be useful. Suppose you have a consumer-producer relationship where one routine creates items and adds them to a queue and another removes items from the queue and uses them. For reasons of efficiency, you want to add and remove several items at once. The
1064:
and similar implementations. In addition to Duff's objections, Tatham's own comments provide a frank evaluation of the limitations of this approach: "As far as I know, this is the worst piece of C hackery ever seen in serious production code." The main shortcomings of this approximation are that, in
572:
where each sub-process is a coroutine. Channel inputs/outputs and blocking operations yield coroutines and a scheduler unblocks them on completion events. Alternatively, each sub-process may be the parent of the one following it in the data pipeline (or preceding it, in which case the pattern can be
230:
and delimited continuations. Full coroutines are either symmetric or asymmetric. Importantly, whether a coroutine is symmetric or asymmetric has no bearing on how expressive it can be as they are equally as expressive, though full coroutines are more expressive than non-full coroutines. While their
1048:
Due to the lack of direct language support, many authors have written their own libraries for coroutines which hide the above details. Russ Cox's libtask library is a good example of this genre. It uses the context functions if they are provided by the native C library; otherwise it provides its
1077:
introduced standardized coroutines as stackless functions that can be suspended in the middle of execution and resumed at a later point. The suspended state of a coroutine is stored on the heap. Implementation of this standard is ongoing, with the G++ and MSVC compilers currently fully supporting
393:
Generators, also known as semicoroutines, are a subset of coroutines. Specifically, while both can yield multiple times, suspending their execution and allowing re-entry at multiple entry points, they differ in coroutines' ability to control where execution continues immediately after they yield,
945:
executing pieces of code. Threads are widely available in environments that support C (and are supported natively in many other modern languages), are familiar to many programmers, and are usually well-implemented, well-documented and well-supported. However, as they solve a large and difficult
244:
Subroutines are special cases of coroutines. When subroutines are invoked, execution begins at the start, and once a subroutine exits, it is finished; an instance of a subroutine only returns once, and does not hold state between invocations. By contrast, coroutines can exit by calling other
1044:
all other registers. This can be significantly faster, as setjmp and longjmp must conservatively store all registers which may be in use according to the ABI, whereas the clobber method allows the compiler to store (by spilling to the stack) only what it knows is actually in use.
378:
It is possible to implement coroutines using preemptively-scheduled threads, in a way that will be transparent to the calling code, but some of the advantages (particularly the suitability for hard-realtime operation and relative cheapness of switching between them) will be lost.
1036:, such that returning to a coroutine after having yielded restores all the state that would be restored upon returning from a function call. Minimalist implementations, which do not piggyback off the setjmp and longjmp functions, may achieve the same result via a small block of 1333:", which are lightweight, independent processes managed by the Go runtime. A new goroutine can be started using the "go" keyword. Each goroutine has a variable-size stack which can be expanded as needed. Goroutines generally communicate using Go's built-in channels. 949:
One important difference between threads and coroutines is that threads are typically preemptively scheduled while coroutines are not. Because threads can be rescheduled at any instant and can execute concurrently, programs using threads must be careful about
1065:
not maintaining a separate stack frame for each coroutine, local variables are not preserved across yields from the function, it is not possible to have multiple entries to the function, and control can only be yielded from the top-level routine.
895:
As of 2003, many of the most popular programming languages, including C and its derivatives, do not have built-in support for coroutines within the language or their standard libraries. This is, in large part, due to the limitations of
954:. In contrast, because coroutines can only be rescheduled at specific points in the program and do not execute concurrently, programs using coroutines can often avoid locking entirely. This property is also cited as a benefit of 1726:
implements native support for coroutines. They are designed to be used with a Gtk Main Loop, but can be used alone if care is taken to ensure that the end callback will never have to be called before doing, at least, one yield.
249:
to it and simply calling another routine (which then, also, would return to the original point), is that the relationship between two coroutines which yield to each other is not that of caller-callee, but instead symmetric.
1857: 996:
system call, a second call stack can be obtained by calling a springboard function from within a signal handler to achieve the same goal in portable C, at the cost of some extra complexity. C libraries complying to
231:
expressive power is the same, asymmetrical coroutines more closely resemble routine based control structures in the sense that control is always passed back to the invoker, which programmers may find more familiar.
1450:
The procedure NEWPROCESS() fills in a context given a code block and space for a stack as parameters, and the procedure TRANSFER() transfers control to a coroutine given the coroutine's context as its parameter.
1345:. Despite the constraints imposed by Java's abstractions, the JVM does not preclude the possibility. There are four general methods used, but two break bytecode portability among standards-compliant JVMs. 576:
Reverse communication, commonly used in mathematical software, wherein a procedure such as a solver, integral evaluator, ... needs the using process to make a computation, such as evaluating an equation or
1271:
provides transparent asynchrony for Silverlight WCF services and ability to asynchronously call any synchronous method. The implementation is based on Caliburn's Coroutines iterator and C# iterator blocks.
946:
problem they include many powerful and complex facilities and have a correspondingly difficult learning curve. As such, when a coroutine is all that is needed, using a thread can be overkill.
1049:
own implementations for ARM, PowerPC, Sparc, and x86. Other notable implementations include libpcl, coro, lthread, libCoroutine, libconcurrency, libcoro, ribs2, libdill., libaco, and libco.
1104:- also created by Oliver Kowalke, is a modernized portable coroutine library since boost version 1.59. It takes advantage of C++11 features, but removes the support for symmetric coroutines. 552:. Each actor has its own procedures (this again logically separates the code), but they voluntarily give up control to central scheduler, which executes them sequentially (this is a form of 961:
Since fibers are cooperatively scheduled, they provide an ideal base for implementing coroutines above. However, system support for fibers is often lacking compared to that for threads.
2871: 1747:
family of minicomputers, the "classic" coroutine switch is effected by the instruction "JSR PC,@(SP)+", which jumps to the address popped from the stack and pushes the current (
1838: 1680: 1374:
Thread abstractions. Coroutine libraries which are implemented using threads may be heavyweight, though performance will vary based on the JVM's thread implementation.
530:
within a single subroutine, where the state is determined by the current entry/exit point of the procedure; this can result in more readable code compared to use of
941:, are an alternative to coroutines in mainstream programming environments today. Threads provide facilities for managing the real-time cooperative interaction of 161:
There is no single precise definition of coroutine. In 1980 Christopher D. Marlin summarized two widely-acknowledged fundamental characteristics of a coroutine:
489:
A number of implementations of coroutines for languages with generator support but no native coroutines (e.g. Python before 2.5) use this or a similar model.
394:
while generators cannot, instead transferring control back to the generator's caller. That is, since generators are primarily used to simplify the writing of
1767:
there is the instruction "JSR "; note the "++", as 2 bytes (of address) are popped from the stack. This instruction is much used in the (standard) 'monitor'
168:
the execution of a coroutine is suspended as control leaves it, only to carry on where it left off when control re-enters the coroutine at some later stage.
188:. Programmers cannot freely choose which frame to yield to. The runtime only yields to the nearest caller of the current coroutine. On the other hand, in 2368: 2189: 1491:
module. These coroutines provide concurrency without parallelism, and are scheduled preemptively on a single operating system thread. Since OCaml 5.0,
1052:
In addition to the general approach above, several attempts have been made to approximate coroutines in C with combinations of subroutines and macros.
1295:. It's implemented as a macro, statically splitting an arbitrary code block on arbitrary var calls and emitting the coroutine as a stateful function. 2028: 908:, which supports context swapping on ARM, MIPS, PowerPC, SPARC and x86 on POSIX, Mac OS X and Windows. Coroutines can be built upon Boost.Context. 1356:
Modified bytecode. Coroutine functionality is possible by rewriting regular Java bytecode, either on the fly or at compile time. Toolkits include
1695:
provides full support for continuations, implementing coroutines is nearly trivial, requiring only that a queue of continuations be maintained.
347:, because they allow tasks to be performed out of order or in a changeable order, without changing the overall outcome, but they do not provide 3113: 2337: 2086: 2011: 1851: 2207: 911:
In situations where a coroutine would be the natural implementation of a mechanism, but is not available, the typical response is to use a
2875: 1279:
is an open-source, light-weight C# co-routine library based on iterator extension methods. It supports error handling and return values.
405:
However, it is still possible to implement coroutines on top of a generator facility, with the aid of a top-level dispatcher routine (a
223: 1846:. The Art of Computer Programming. Vol. 1 (3rd ed.). Addison-Wesley. Section 1.4.5: History and Bibliography, pp. 229. 1084:- a C++20 library which provides third-party support for C++20 coroutines, in the form of awaitable-tasks and executors that run them. 569: 351:, because they do not execute multiple tasks simultaneously. The advantages of coroutines over threads are that they may be used in a 1371:
Platform-specific JNI mechanisms. These use JNI methods implemented in the OS or C libraries to provide the functionality to the JVM.
222:
to denote one that supports first-class coroutine and is stackful. Full Coroutines deserve their own name in that they have the same
2131: 1938: 1707:
environments, the execution stack is a first-class citizen, coroutines can be implemented without additional library or VM support.
84: 2523: 1223: 1188: 609: 559: 388: 2740: 855: 591: 58: 515:
is implemented), while passing control between coroutines uses the existing contexts and can be implemented simply by a jump.
3095: 707: 681: 645: 344: 2853: 2006:. The Art of Computer Programming. Vol. 1 (3rd ed.). Addison-Wesley. Section 1.4.2: Coroutines, pp. 193–200. 3222: 1692: 1641: 1609: 1594: 1584: 1574: 1564: 1543: 1414: 834: 814: 808: 742: 686: 676: 651: 619: 1230:) screen patterns framework for WPF uses C# 2.0 iterators to ease UI programming, particularly in asynchronous scenarios. 981:
to explicitly manipulate the stack pointer during initial creation of the coroutine. This is the approach recommended by
1033: 758: 748: 737: 409:, essentially) that passes control explicitly to child generators identified by tokens passed back from the generators: 1240: 887:
can be used to implement coroutines, programming languages that support them can also quite easily support coroutines.
1723: 1671: 1656: 1511: 1342: 1251:
implements an AsyncEnumerator that provides simplified Asynchronous Programming Model using iterator-based coroutines.
839: 824: 819: 717: 629: 402:
statement in a generator does not specify a coroutine to jump to, but rather passes a value back to a parent routine.
109: 2232: 1644:
provides native continuations, with a trivial implementation of coroutines provided in the official package catalog.
3055: 931:. Such implementations are considered difficult to understand and maintain, and a motivation for coroutine support. 1425: 1020:
can then be used to implement the switches between coroutines. These functions save and restore, respectively, the
912: 753: 661: 599: 2691: 2983: 1886: 1547: 1330: 1326: 1002: 722: 702: 2246: 2494: 1393: 1303: 974: 955: 938: 666: 553: 336: 113: 66: 62: 46: 2365: 202:
whether a coroutine is able to suspend its execution from within nested function calls. Such a coroutine is a
1476: 951: 1428:
has supported first-class stackful asymmetric coroutines since version 5.0 (2003), in the standard library
1101: 3161: 1963: 1087: 566: – particularly input/output – and for generic traversal of data structures. 406: 340: 246: 3034: 2314: 2058: 1095: 901: 512: 304:
The queue is then completely filled or emptied before yielding control to the other coroutine using the
2175: 2161: 1167:- stackless coroutines with scheduling designed for high-concurrency level I/O operations. Used in the 1812: 3227: 1248: 1131: 364: 2667: 2296: 3166: 2063:
6. Symmetry is a complexity reducing concept (co-routines include sub-routines); seek it everywhere
1968: 1268: 1255: 712: 696: 196: 133: 2393: 3179: 3119: 2593: 2050: 1981: 1911: 1768: 1029: 1017: 993: 934: 563: 348: 332: 316: 117: 2565:"libcoro: C-library that implements coroutines (cooperative multitasking) in a portable fashion" 977:
language. A reliable (albeit platform-specific) way to achieve this is to use a small amount of
2115: 1114:
open sourced a C++ library implementing coroutines, with an emphasis on using them to abstract
3201: 3109: 2966: 2640: 2333: 2211: 2082: 2007: 1934: 1903: 1847: 1736: 1567:
2.5 implements better support for coroutine-like functionality, based on extended generators (
1349:
Modified JVMs. It is possible to build a patched JVM to support coroutines more natively. The
1139: 691: 587: 372: 150: 1551: 1402: 1213:
REST framework provides an implementation of coroutines based on the C# 2.0 iterator pattern.
3171: 3101: 2717: 2040: 1973: 1895: 1218: 1115: 1057: 920: 860: 535: 504: 498: 101: 2936:
de Moura, Ana LΓΊcia; Rodriguez, Noemi; Ierusalimschy, Roberto (2004). "Coroutines in Lua".
2679: 1463:
Common Language Runtime has support for continuations, from which coroutines can be built.
1405:, stackless coroutine functionality through "generators" and yield expressions is provided. 2549: 2498: 2372: 1785: 1460: 1244: 1037: 1025: 978: 916: 763: 129: 2448: 2139: 2703: 2527: 1715:
Since version 8.6, the Tool Command Language supports coroutines in the core language.
1472: 1357: 1307: 1013: 426:
q is not full create some new items add the items to q
356: 278:
q is not full create some new items add the items to q
2706:- EricWF: Coroutines are now in Clang Trunk! Working on the Libc++ implementation now. 2623:"A blazing fast and lightweight C asymmetric coroutine library πŸ’Ž β›…πŸš€β›…πŸŒž: hnes/libaco" 2278: 440:
q is not empty remove some items from q use the items
293:
q is not empty remove some items from q use the items
3216: 2376: 1874: 1764: 1444: 1227: 1021: 1012:
Once a second call stack has been obtained with one of the methods listed above, the
928: 865: 527: 352: 142: 3206: 2054: 1915: 1523: 1090:- created by Oliver Kowalke, is the official released portable coroutine library of 3197: 3183: 1985: 1791: 1492: 1392:- fibjs is a JavaScript runtime built on Chrome's V8 JavaScript engine. fibjs uses 1125: 1053: 986: 884: 623: 360: 227: 3127: 3123: 3073: 1645: 1168: 199:, which can be freely manipulated by the programmer, or as constrained constructs; 112:. Coroutines are well-suited for implementing familiar program components such as 2076: 1275: 323:
statement can be implemented by a jump directly from one routine into the other.
2353: 2260: 1794:, a stackless lightweight thread implementation using a coroutine like mechanism 1780: 1235: 1196: 1184: 1061: 604: 545: 2692:
http://mozy.com/blog/announcements/open-source-and-mozy-the-debut-of-mozy-code/
2410:
Portable Multithreading – The Signal Stack Trick For User-Space Thread Creation
2110: 811:(since 2.5, with improved support since 3.3 and with explicit syntax since 3.5) 3006: 2580:"RIBS (Robust Infrastructure for Backend Systems) version 2: aolarchive/ribs2" 2564: 2468:- Russ Cox's libtask coroutine library for FreeBSD, Linux, Mac OS X, and SunOS 2408: 1931:
Coroutines: A Programming Methodology, a Language Design and an Implementation
1660: 1620: 1098:
and supports ARM, MIPS, PowerPC, SPARC and X86 on POSIX, Mac OS X and Windows.
1041: 1006: 970: 897: 876: 727: 549: 121: 105: 2970: 2762: 2654: 1907: 1878: 1666: 1587:
3.4 introduces a comprehensive asynchronous I/O framework as standardized in
1081: 210:, where unless marked as coroutine, a regular function can't use the keyword 3175: 3105: 3094:
Ritchie, Dennis M. (1980). "The evolution of the unix time-sharing system".
2954: 2748: 2725: 1977: 1760: 1704: 1675: 1602: 1588: 1578: 1568: 1263: 850: 671: 539: 508: 153:. The first published explanation of the coroutine appeared later, in 1963. 3152:
Ana Lucia de Moura; Roberto Ierusalimschy (2004). "Revisiting Coroutines".
2328:
Dahl, O.J.; Hoare, C.A.R., eds. (1972). "Hierarchical Program Structures".
2045: 1954:
Ana Lucia de Moura; Roberto Ierusalimschy (2009). "Revisiting Coroutines".
1138:
project implements a light-weight version of stackless coroutines based on
367:
calls whatsoever), there is no need for synchronization primitives such as
2655:"Stackless coroutine implementation in C and C++: jsseldenthuis/coroutine" 1899: 1384: 1365: 1164: 1148:- C++11 single .h asymmetric coroutine implementation via ucontext / fiber 104:
components that allow execution to be suspended and resumed, generalizing
17: 3059: 1740: 1440: 1350: 982: 798: 792: 768: 395: 165:
the values of data local to a coroutine persist between successive calls;
125: 2786: 1539: 1361: 1288: 1074: 730:(since 1.7, standardized in ECMAScript 6) ECMAScript 2017 also includes 1577:
3.3 improves this ability, by supporting delegating to a subgenerator (
1292: 1291:
is a third-party library providing support for stackless coroutines in
1135: 773: 503:
Using coroutines for state machines or concurrency is similar to using
139:
They have been described as "functions whose execution you can pause".
3020: 2579: 1739:
often provide direct methods for coroutine execution. For example, in
1145: 2510: 2477: 1744: 1674:
2.5 and higher supports coroutines natively which are implemented as
1209: 844: 829: 803: 778: 2908: 2810: 2491: 2366:
Implementing Coroutines for .NET by Wrapping the Unmanaged Fiber API
1554:
showing there code converted with same number of lines and behavior.
253:
Any subroutine can be translated to a coroutine which does not call
3100:. Lecture Notes in Computer Science. Vol. 79. pp. 25–35. 2889: 2513:- lthread is a multicore/multithread coroutine library written in C 2354:"Rethinking the Computer Music Programming Language: SuperCollider" 1504: 1396:, sync style, and non-blocking I/O model to build scalable systems. 973:
must be obtained, which is a feature not directly supported by the
639: 308:
command. The further coroutines calls are starting right after the
65:
external links, and converting useful links where appropriate into
1598: 1200: 1158: 1152: 1121: 998: 990: 731: 656: 634: 368: 218:
The paper "Revisiting Coroutines" published in 2009 proposed term
2668:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/n4680.pdf
2622: 2162:"Coroutine: Type-safe coroutines using lightweight session types" 1591:, which includes coroutines that leverage subgenerator delegation 1389: 1172: 1107: 2835:"Frequently Asked Questions (FAQ) - The Go Programming Language" 1111: 924: 782: 614: 531: 3209: – contains extensive assembler coroutines links 2907:
de Moura, Ana LΓΊcia; Rodriguez, Noemi; Ierusalimschy, Roberto.
2539:
for FreeBSD, Linux, OS X PPC and x86, SunOS, Symbian and others
2430: 1756: 1447:
implements coroutines as part of the standard SYSTEM library.
1318:, making any fiber compatible with existing range algorithms. 1040:
which swaps merely the stack pointer and program counter, and
1009:, but these functions were declared obsolete in POSIX 1.2008. 985:
in a discussion on its relative merits vs. the method used by
870: 788: 375:, and there is no need for support from the operating system. 29: 1788:, a kind of coroutine used for communicating between programs 2465: 2116:
https://docs.python.org/reference/expressions.html#yieldexpr
1630: 2967:
http://blogs.msdn.com/cbrumme/archive/2004/02/21/77595.aspx
2501:- Edgar Toernig's coro library for x86, Linux & FreeBSD 969:
In order to implement general-purpose coroutines, a second
900:
subroutine implementation. An exception is the C++ library
2554:
a simple C library for portable stack-switching coroutines
1659:
1.9 supports coroutines natively which are implemented as
1597:
3.5 introduces explicit support for coroutines with async/
1534: 1060:, is a notable example of the genre, and is the basis for 315:
Although this example is often used as an introduction to
2834: 172:
Besides that, a coroutine implementation has 3 features:
2680:
https://en.cppreference.com/w/cpp/compiler_support#cpp20
1763:) the comparable instruction is "JSB @(SP)+". Even on a 1625: 1417:
implements coroutines as part of a first-party library.
2550:"libconcurrency - A scalable concurrency library for C" 2356:. Computer Music Journal, 26(4):61-68. MIT Press, 2002. 1615: 905: 54: 2601: 2233:"Julia Manual - Control Flow - Tasks (aka Coroutines)" 3154:
ACM Transactions on Programming Languages and Systems
2872:"Holy crap: JVM has coroutine/continuation/fiber etc" 2416:. USENIX Annual Technical Conference. San Diego, USA. 2297:"8. Compound statements β€” Python 3.8.0 documentation" 1956:
ACM Transactions on Programming Languages and Systems
1529: 915: – a subroutine with state variables ( 149:
in 1958 when he applied it to the construction of an
2704:
https://twitter.com/eric01/status/867473461836263424
1341:
There are several implementations for coroutines in
1306:
implements coroutines as its standard library class
2524:"libcoroutine: A portable coroutine implementation" 1879:"Design of a Separable Transition-diagram Compiler" 1813:"How the heck does async/await work in Python 3.5?" 1495:are also available; provided by different modules. 1091: 1007:
getcontext, setcontext, makecontext and swapcontext
195:whether coroutines are provided in the language as 2682:- Current compiler support for standard coroutines 1314:makes it trivial to expose a fiber function as an 1032:, and any other internal state as required by the 523:Coroutines are useful to implement the following: 1997: 1995: 1191:) functionality through the iterator pattern and 49:may not follow Knowledge's policies or guidelines 2332:. London, UK: Academic Press. pp. 175–220. 1155:in May 2017, with libc++ implementation ongoing. 3074:"coroutine manual page - Tcl Built-In Commands" 1612:3.7, async/await have become reserved keywords. 192:, programmers must specify a yield destination. 2694:- Open Source and Mozy: The Debut of Mozy Code 2751:. C# version 2.0 – via Microsoft Learn. 8: 3097:Language Design and Programming Methodology 2569:used as the basis for the Coro perl module. 1510:Coroutines are natively implemented in all 319:, two threads are not needed for this: the 1475:2.0, Microsoft extended the design of the 1094:since version 1.53. The library relies on 3165: 2955:http://www.mono-project.com/Continuations 2634: 2632: 2044: 1967: 1755:) instruction address onto the stack. On 1667:An implementation by Marc De Scheemaecker 85:Learn how and when to remove this message 3202:comprehensive introduction to coroutines 2670:- Technical specification for coroutines 2482:- C library using POSIX/SUSv3 facilities 2425: 2423: 2190:"The Coroutines Module (coroutines.hhf)" 1128:tricks, providing await/yield emulation. 359:between coroutines need not involve any 2407:Ralf S. Engelschall (18–23 June 2000). 2388: 2386: 2384: 1804: 1078:standard coroutines in recent versions. 2787:"Go statements - The Go Specification" 2625:. October 21, 2019 – via GitHub. 1487:OCaml supports coroutines through its 1118:into a more familiar sequential model. 2938:Journal of Universal Computer Science 2582:. August 13, 2019 – via GitHub. 1681:An implementation by Thomas W Branson 371:, semaphores, etc. in order to guard 7: 2657:. March 18, 2019 – via GitHub. 2138:. IBM developerWorks. Archived from 1542:implemented in a way that resembles 2449:"getcontext(3) - Linux manual page" 1124:- stackless coroutine based on C++ 2511:https://github.com/halayli/lthread 2027:Perlis, Alan J. (September 1982). 1258:game engine implements coroutines. 1005:(SUSv3) provided such routines as 590:method, but are supported in some 570:Communicating sequential processes 534:, and may also be implemented via 25: 2739:Wagner, Bill (13 February 2023). 2716:Wagner, Bill (11 November 2021). 2492:http://www.goron.de/~froese/coro/ 1646:Implementation by S. De Gabrielle 1171:experiment by Oat++. Part of the 989:. On platforms which provide the 2132:"Generator-based State Machines" 2078:Encyclopedia of computer science 1918:– via ACM Digital Library. 1863:from the original on 2019-10-21. 592:high-level programming languages 573:expressed as nested generators). 548:of concurrency, for instance in 478:current current := 389:Generator (computer programming) 339:, whereas threads are typically 206:. One to the contrary is called 176:the control-transfer mechanism. 34: 2870:Remi Forax (19 November 2009). 1743:, the assembly language of the 1169:5-million WebSocket connections 331:Coroutines are very similar to 312:, in the outer coroutine loop. 2394:"Coroutines in C – brainwagon" 1471:During the development of the 180:usually provide keywords like 1: 2982:kexugit (15 September 2005). 2279:"Python async/await Tutorial" 2130:Mertz, David (July 1, 2002). 2111:The Python Language Reference 1203:syntax support. In addition: 958:or asynchronous programming. 815:Racket (programming language) 2728:– via Microsoft Learn. 2118:5.2.10. Yield expressions]": 2002:Knuth, Donald Ervin (1997). 1929:Marlin, Christopher (1980). 1837:Knuth, Donald Ervin (1997). 1663:, which are semi-coroutines. 699:(Godot's scripting language) 586:Coroutines originated as an 471:current := produce 3207:Softpanorama coroutine page 2811:"Goroutines - A Tour of Go" 2763:"Goroutines - Effective Go" 2194:HLA Standard Library Manual 1711:Tool Command Language (Tcl) 1329:has a built-in concept of " 562:, and these are useful for 261:code might look like this: 27:Computer software component 3244: 3035:"What's New in Python 3.7" 2479:Portable Coroutine Library 2315:"Gather and/or Coroutines" 2261:"Lua 5.2 Reference Manual" 2247:"What's New in Kotlin 1.1" 1056:'s contribution, based on 927:statement, particularly a 496: 386: 335:. However, coroutines are 2466:http://swtch.com/libtask/ 2029:"Epigrams on programming" 1887:Communications of the ACM 1003:Single Unix Specification 937:, and to a lesser extent 626:7.0 with uThreads module) 451:d := new dictionary( 337:cooperatively multitasked 2176:"Co-routines in Haskell" 2075:Anthony Ralston (2000). 1353:has had patches created. 554:cooperative multitasking 341:preemptively multitasked 110:cooperative multitasking 3176:10.1145/1462166.1462167 3106:10.1007/3-540-09745-7_2 2984:"Fiber mode is gone..." 2208:"New in JavaScript 1.7" 1978:10.1145/1462166.1462167 1477:Common Language Runtime 1236:Power Threading Library 795:, native since PHP 5.5) 2859:. JVM Language Summit. 2852:Lukas Stadler (2009). 2330:Structured Programming 2046:10.1145/947955.1083808 2004:Fundamental Algorithms 1840:Fundamental Algorithms 1187:added semi-coroutine ( 1140:Simon Tatham's article 463:consume d := 3007:"The threads library" 2890:"Lua version history" 2639:Simon Tatham (2000). 2081:. Nature Pub. Group. 2061:on January 17, 1999. 1900:10.1145/366663.366704 1817:Tall, Snarky Canadian 1151:Coroutines landed in 513:tail call elimination 497:Further information: 343:. Coroutines provide 178:asymmetric coroutines 3223:Concurrent computing 3062:on October 24, 2007. 2285:. December 17, 2015. 2142:on February 28, 2009 1546:functions, and some 1526:native since PHP 8.1 415:q := new queue 267:q := new queue 208:stackless coroutines 190:symmetric coroutines 157:Definition and types 55:improve this article 2909:"Coroutines in Lua" 2854:"JVM Continuations" 2741:"The history of C#" 2033:ACM SIGPLAN Notices 1894:(7). ACM: 396–408. 713:High Level Assembly 197:first-class objects 67:footnote references 2987:docs.microsoft.com 2957:Mono Continuations 2497:2006-01-10 at the 2371:2008-09-07 at the 1737:assembly languages 1735:Machine-dependent 1731:Assembly languages 1243:2010-03-24 at the 1018:standard C library 1014:setjmp and longjmp 204:stackful coroutine 3115:978-3-540-09745-7 3056:"semi-coroutines" 2878:on 19 March 2015. 2641:"Coroutines in C" 2339:978-0-12-200550-3 2088:978-1-56159-248-7 2013:978-0-201-89683-1 1875:Conway, Melvin E. 1853:978-0-201-89683-1 1146:tonbit::coroutine 1016:functions in the 692:GameMonkey Script 588:assembly language 373:critical sections 114:cooperative tasks 95: 94: 87: 16:(Redirected from 3235: 3187: 3169: 3139: 3138: 3136: 3135: 3126:. Archived from 3091: 3085: 3084: 3082: 3081: 3070: 3064: 3063: 3058:. Archived from 3052: 3046: 3045: 3043: 3041: 3031: 3025: 3024: 3017: 3011: 3010: 3003: 2997: 2996: 2994: 2993: 2979: 2973: 2971:cbrumme's WebLog 2969:, Chris Brumme, 2964: 2958: 2952: 2946: 2945: 2933: 2927: 2926: 2924: 2922: 2913: 2904: 2898: 2897: 2886: 2880: 2879: 2874:. Archived from 2867: 2861: 2860: 2858: 2849: 2843: 2842: 2831: 2825: 2824: 2822: 2821: 2807: 2801: 2800: 2798: 2797: 2783: 2777: 2776: 2774: 2773: 2759: 2753: 2752: 2745:C# documentation 2736: 2730: 2729: 2722:C# documentation 2713: 2707: 2701: 2695: 2689: 2683: 2677: 2671: 2665: 2659: 2658: 2651: 2645: 2644: 2636: 2627: 2626: 2619: 2613: 2612: 2610: 2609: 2600:. Archived from 2590: 2584: 2583: 2576: 2570: 2568: 2561: 2555: 2553: 2546: 2540: 2538: 2536: 2535: 2526:. Archived from 2520: 2514: 2508: 2502: 2489: 2483: 2475: 2469: 2463: 2457: 2456: 2445: 2439: 2438: 2427: 2418: 2417: 2415: 2404: 2398: 2397: 2390: 2379: 2375:, Ajai Shankar, 2363: 2357: 2350: 2344: 2343: 2325: 2319: 2318: 2311: 2305: 2304: 2293: 2287: 2286: 2275: 2269: 2268: 2257: 2251: 2250: 2243: 2237: 2236: 2229: 2223: 2222: 2220: 2219: 2210:. Archived from 2204: 2198: 2197: 2186: 2180: 2179: 2172: 2166: 2165: 2158: 2152: 2151: 2149: 2147: 2127: 2121: 2108:See for example 2106: 2100: 2099: 2097: 2095: 2072: 2066: 2065: 2057:. Archived from 2048: 2024: 2018: 2017: 1999: 1990: 1989: 1971: 1951: 1945: 1944: 1926: 1920: 1919: 1883: 1871: 1865: 1864: 1862: 1845: 1834: 1828: 1827: 1825: 1824: 1809: 1631:stackless python 1490: 1194: 1165:oatpp-coroutines 1116:asynchronous I/O 1102:Boost.Coroutine2 921:switch statement 917:static variables 861:Stackless Python 536:mutual recursion 505:mutual recursion 499:Mutual recursion 493:Mutual recursion 459:) d := 401: 224:expressive power 213: 187: 183: 151:assembly program 145:coined the term 102:computer program 90: 83: 79: 76: 70: 38: 37: 30: 21: 3243: 3242: 3238: 3237: 3236: 3234: 3233: 3232: 3213: 3212: 3194: 3151: 3148: 3146:Further reading 3143: 3142: 3133: 3131: 3116: 3093: 3092: 3088: 3079: 3077: 3072: 3071: 3067: 3054: 3053: 3049: 3039: 3037: 3033: 3032: 3028: 3019: 3018: 3014: 3005: 3004: 3000: 2991: 2989: 2981: 2980: 2976: 2965: 2961: 2953: 2949: 2935: 2934: 2930: 2920: 2918: 2911: 2906: 2905: 2901: 2888: 2887: 2883: 2869: 2868: 2864: 2856: 2851: 2850: 2846: 2833: 2832: 2828: 2819: 2817: 2809: 2808: 2804: 2795: 2793: 2785: 2784: 2780: 2771: 2769: 2761: 2760: 2756: 2738: 2737: 2733: 2715: 2714: 2710: 2702: 2698: 2690: 2686: 2678: 2674: 2666: 2662: 2653: 2652: 2648: 2638: 2637: 2630: 2621: 2620: 2616: 2607: 2605: 2592: 2591: 2587: 2578: 2577: 2573: 2563: 2562: 2558: 2548: 2547: 2543: 2533: 2531: 2522: 2521: 2517: 2509: 2505: 2499:Wayback Machine 2490: 2486: 2476: 2472: 2464: 2460: 2447: 2446: 2442: 2429: 2428: 2421: 2413: 2406: 2405: 2401: 2396:. 5 March 2005. 2392: 2391: 2382: 2373:Wayback Machine 2364: 2360: 2351: 2347: 2340: 2327: 2326: 2322: 2313: 2312: 2308: 2301:docs.python.org 2295: 2294: 2290: 2277: 2276: 2272: 2259: 2258: 2254: 2245: 2244: 2240: 2231: 2230: 2226: 2217: 2215: 2206: 2205: 2201: 2188: 2187: 2183: 2174: 2173: 2169: 2160: 2159: 2155: 2145: 2143: 2136:Charming Python 2129: 2128: 2124: 2119: 2107: 2103: 2093: 2091: 2089: 2074: 2073: 2069: 2026: 2025: 2021: 2014: 2001: 2000: 1993: 1953: 1952: 1948: 1941: 1928: 1927: 1923: 1881: 1873: 1872: 1868: 1860: 1854: 1843: 1836: 1835: 1831: 1822: 1820: 1811: 1810: 1806: 1801: 1777: 1733: 1721: 1713: 1703:Since, in most 1701: 1689: 1653: 1639: 1561: 1520: 1501: 1488: 1485: 1469: 1457: 1438: 1423: 1412: 1403:ECMAScript 2015 1381: 1362:Java Coroutines 1339: 1324: 1301: 1286: 1264:Servelat Pieces 1249:Jeffrey Richter 1245:Wayback Machine 1210:MindTouch Dream 1192: 1182: 1088:Boost.Coroutine 1071: 1038:inline assembly 1028:, callee-saved 1026:program counter 979:inline assembly 967: 906:boost libraries 893: 891:Implementations 881: 584: 521: 501: 495: 487: 447:dispatcher 399: 391: 385: 329: 302: 242: 237: 235:Comparison with 211: 185: 181: 159: 91: 80: 74: 71: 52: 43:This article's 39: 35: 28: 23: 22: 15: 12: 11: 5: 3241: 3239: 3231: 3230: 3225: 3215: 3214: 3211: 3210: 3204: 3200:'s C oriented 3193: 3192:External links 3190: 3189: 3188: 3167:10.1.1.58.4017 3147: 3144: 3141: 3140: 3114: 3086: 3065: 3047: 3026: 3012: 2998: 2974: 2959: 2947: 2944:(7): 901--924. 2928: 2899: 2881: 2862: 2844: 2826: 2802: 2778: 2754: 2731: 2708: 2696: 2684: 2672: 2660: 2646: 2628: 2614: 2585: 2571: 2556: 2541: 2515: 2503: 2484: 2470: 2458: 2440: 2419: 2399: 2380: 2358: 2352:McCartney, J. 2345: 2338: 2320: 2306: 2288: 2270: 2252: 2238: 2224: 2199: 2181: 2167: 2153: 2122: 2101: 2087: 2067: 2019: 2012: 1991: 1969:10.1.1.58.4017 1946: 1939: 1921: 1866: 1852: 1829: 1803: 1802: 1800: 1797: 1796: 1795: 1789: 1783: 1776: 1773: 1732: 1729: 1720: 1717: 1712: 1709: 1700: 1697: 1688: 1685: 1684: 1683: 1678: 1669: 1664: 1652: 1649: 1638: 1635: 1634: 1633: 1628: 1623: 1618: 1613: 1606: 1592: 1582: 1572: 1560: 1557: 1556: 1555: 1537: 1532: 1527: 1519: 1516: 1508: 1507: 1500: 1497: 1484: 1481: 1473:.NET Framework 1468: 1467:.NET Framework 1465: 1456: 1453: 1443:as defined by 1437: 1434: 1422: 1419: 1411: 1408: 1407: 1406: 1399: 1398: 1397: 1380: 1377: 1376: 1375: 1372: 1369: 1354: 1338: 1335: 1323: 1320: 1300: 1297: 1285: 1282: 1281: 1280: 1272: 1259: 1252: 1231: 1226:2013-01-19 at 1214: 1181: 1178: 1177: 1176: 1175:web framework. 1162: 1156: 1149: 1143: 1129: 1119: 1105: 1099: 1085: 1079: 1070: 1067: 966: 963: 943:simultaneously 892: 889: 880: 879: 874: 868: 863: 858: 853: 848: 842: 837: 832: 827: 822: 817: 812: 806: 801: 796: 786: 776: 771: 766: 761: 756: 751: 746: 740: 735: 725: 720: 715: 710: 705: 700: 694: 689: 684: 679: 674: 669: 664: 659: 654: 649: 643: 637: 632: 627: 617: 612: 607: 602: 596: 583: 582:Native support 580: 579: 578: 574: 567: 557: 543: 528:State machines 520: 517: 494: 491: 411: 387:Main article: 384: 381: 328: 325: 317:multithreading 263: 241: 238: 236: 233: 220:full coroutine 216: 215: 200: 193: 170: 169: 166: 158: 155: 130:infinite lists 93: 92: 47:external links 42: 40: 33: 26: 24: 14: 13: 10: 9: 6: 4: 3: 2: 3240: 3229: 3226: 3224: 3221: 3220: 3218: 3208: 3205: 3203: 3199: 3196: 3195: 3191: 3185: 3181: 3177: 3173: 3168: 3163: 3159: 3155: 3150: 3149: 3145: 3130:on 2015-04-08 3129: 3125: 3121: 3117: 3111: 3107: 3103: 3099: 3098: 3090: 3087: 3075: 3069: 3066: 3061: 3057: 3051: 3048: 3036: 3030: 3027: 3022: 3016: 3013: 3008: 3002: 2999: 2988: 2985: 2978: 2975: 2972: 2968: 2963: 2960: 2956: 2951: 2948: 2943: 2939: 2932: 2929: 2917: 2910: 2903: 2900: 2895: 2891: 2885: 2882: 2877: 2873: 2866: 2863: 2855: 2848: 2845: 2840: 2836: 2830: 2827: 2816: 2812: 2806: 2803: 2792: 2788: 2782: 2779: 2768: 2764: 2758: 2755: 2750: 2746: 2742: 2735: 2732: 2727: 2723: 2719: 2712: 2709: 2705: 2700: 2697: 2693: 2688: 2685: 2681: 2676: 2673: 2669: 2664: 2661: 2656: 2650: 2647: 2642: 2635: 2633: 2629: 2624: 2618: 2615: 2604:on 2019-12-02 2603: 2599: 2595: 2589: 2586: 2581: 2575: 2572: 2566: 2560: 2557: 2551: 2545: 2542: 2530:on 2019-11-12 2529: 2525: 2519: 2516: 2512: 2507: 2504: 2500: 2496: 2493: 2488: 2485: 2481: 2480: 2474: 2471: 2467: 2462: 2459: 2454: 2450: 2444: 2441: 2436: 2435:code.byuu.org 2432: 2426: 2424: 2420: 2412: 2411: 2403: 2400: 2395: 2389: 2387: 2385: 2381: 2378: 2377:MSDN Magazine 2374: 2370: 2367: 2362: 2359: 2355: 2349: 2346: 2341: 2335: 2331: 2324: 2321: 2317:. 2012-12-19. 2316: 2310: 2307: 2302: 2298: 2292: 2289: 2284: 2280: 2274: 2271: 2266: 2262: 2256: 2253: 2248: 2242: 2239: 2234: 2228: 2225: 2214:on 2009-03-08 2213: 2209: 2203: 2200: 2195: 2191: 2185: 2182: 2177: 2171: 2168: 2163: 2157: 2154: 2141: 2137: 2133: 2126: 2123: 2117: 2113: 2112: 2105: 2102: 2090: 2084: 2080: 2079: 2071: 2068: 2064: 2060: 2056: 2052: 2047: 2042: 2038: 2034: 2030: 2023: 2020: 2015: 2009: 2005: 1998: 1996: 1992: 1987: 1983: 1979: 1975: 1970: 1965: 1961: 1957: 1950: 1947: 1942: 1940:3-540-10256-6 1936: 1932: 1925: 1922: 1917: 1913: 1909: 1905: 1901: 1897: 1893: 1889: 1888: 1880: 1877:(July 1963). 1876: 1870: 1867: 1859: 1855: 1849: 1842: 1841: 1833: 1830: 1818: 1814: 1808: 1805: 1798: 1793: 1790: 1787: 1784: 1782: 1779: 1778: 1774: 1772: 1770: 1766: 1765:Motorola 6809 1762: 1758: 1754: 1750: 1746: 1742: 1738: 1730: 1728: 1725: 1718: 1716: 1710: 1708: 1706: 1698: 1696: 1694: 1686: 1682: 1679: 1677: 1673: 1670: 1668: 1665: 1662: 1658: 1655: 1654: 1650: 1648: 1647: 1643: 1636: 1632: 1629: 1627: 1624: 1622: 1619: 1617: 1614: 1611: 1607: 1604: 1600: 1596: 1593: 1590: 1586: 1583: 1580: 1576: 1573: 1570: 1566: 1563: 1562: 1558: 1553: 1549: 1545: 1541: 1538: 1536: 1533: 1531: 1528: 1525: 1522: 1521: 1517: 1515: 1513: 1506: 1503: 1502: 1498: 1496: 1494: 1493:green threads 1482: 1480: 1478: 1474: 1466: 1464: 1462: 1454: 1452: 1448: 1446: 1442: 1435: 1433: 1431: 1427: 1420: 1418: 1416: 1409: 1404: 1400: 1395: 1394:fibers-switch 1391: 1388: 1387: 1386: 1383: 1382: 1378: 1373: 1370: 1367: 1363: 1359: 1355: 1352: 1348: 1347: 1346: 1344: 1336: 1334: 1332: 1328: 1321: 1319: 1317: 1313: 1309: 1305: 1298: 1296: 1294: 1290: 1283: 1278: 1277: 1276:StreamThreads 1273: 1270: 1269:Yevhen Bobrov 1266: 1265: 1260: 1257: 1253: 1250: 1246: 1242: 1238: 1237: 1232: 1229: 1228:archive.today 1225: 1221: 1220: 1215: 1212: 1211: 1206: 1205: 1204: 1202: 1198: 1190: 1186: 1179: 1174: 1170: 1166: 1163: 1160: 1157: 1154: 1150: 1147: 1144: 1141: 1137: 1133: 1130: 1127: 1123: 1120: 1117: 1113: 1109: 1106: 1103: 1100: 1097: 1096:Boost.Context 1093: 1089: 1086: 1083: 1080: 1076: 1073: 1072: 1068: 1066: 1063: 1059: 1058:Duff's device 1055: 1050: 1046: 1043: 1039: 1035: 1031: 1027: 1023: 1022:stack pointer 1019: 1015: 1010: 1008: 1004: 1000: 995: 992: 988: 984: 980: 976: 972: 964: 962: 959: 957: 953: 947: 944: 940: 936: 932: 930: 929:computed goto 926: 922: 918: 914: 909: 907: 903: 902:Boost.Context 899: 890: 888: 886: 885:continuations 878: 875: 872: 869: 867: 866:SuperCollider 864: 862: 859: 857: 854: 852: 849: 846: 843: 841: 838: 836: 833: 831: 828: 826: 823: 821: 818: 816: 813: 810: 807: 805: 802: 800: 797: 794: 790: 787: 784: 780: 777: 775: 772: 770: 767: 765: 762: 760: 757: 755: 752: 750: 747: 744: 741: 739: 736: 733: 729: 726: 724: 721: 719: 716: 714: 711: 709: 706: 704: 701: 698: 695: 693: 690: 688: 685: 683: 680: 678: 675: 673: 670: 668: 665: 663: 660: 658: 655: 653: 650: 647: 644: 642:(Since C++20) 641: 638: 636: 633: 631: 628: 625: 621: 618: 616: 613: 611: 608: 606: 603: 601: 598: 597: 595: 593: 589: 581: 575: 571: 568: 565: 561: 558: 555: 551: 547: 544: 541: 537: 533: 529: 526: 525: 524: 518: 516: 514: 510: 506: 500: 492: 490: 485: 481: 477: 474: 470: 466: 462: 458: 454: 450: 446: 443: 439: 436: 432: 429: 425: 422: 418: 414: 410: 408: 403: 397: 390: 382: 380: 376: 374: 370: 366: 362: 358: 354: 353:hard-realtime 350: 346: 342: 338: 334: 326: 324: 322: 318: 313: 311: 307: 300: 296: 292: 289: 285: 281: 277: 274: 270: 266: 262: 258: 256: 251: 248: 239: 234: 232: 229: 228:continuations 225: 221: 209: 205: 201: 198: 194: 191: 179: 175: 174: 173: 167: 164: 163: 162: 156: 154: 152: 148: 144: 143:Melvin Conway 140: 137: 135: 131: 127: 123: 119: 115: 111: 107: 103: 99: 89: 86: 78: 68: 64: 63:inappropriate 60: 56: 50: 48: 41: 32: 31: 19: 3198:Simon Tatham 3157: 3153: 3132:. Retrieved 3128:the original 3096: 3089: 3078:. Retrieved 3068: 3060:the original 3050: 3040:10 September 3038:. Retrieved 3029: 3015: 3001: 2990:. Retrieved 2986: 2977: 2962: 2950: 2941: 2937: 2931: 2919:. Retrieved 2915: 2902: 2893: 2884: 2876:the original 2865: 2847: 2838: 2829: 2818:. Retrieved 2814: 2805: 2794:. Retrieved 2790: 2781: 2770:. Retrieved 2766: 2757: 2744: 2734: 2721: 2711: 2699: 2687: 2675: 2663: 2649: 2617: 2606:. Retrieved 2602:the original 2597: 2588: 2574: 2559: 2544: 2532:. Retrieved 2528:the original 2518: 2506: 2487: 2478: 2473: 2461: 2452: 2443: 2434: 2409: 2402: 2361: 2348: 2329: 2323: 2309: 2300: 2291: 2282: 2273: 2264: 2255: 2241: 2227: 2216:. Retrieved 2212:the original 2202: 2193: 2184: 2170: 2156: 2144:. Retrieved 2140:the original 2135: 2125: 2109: 2104: 2092:. Retrieved 2077: 2070: 2062: 2059:the original 2036: 2032: 2022: 2003: 1959: 1955: 1949: 1933:. Springer. 1930: 1924: 1891: 1885: 1869: 1839: 1832: 1821:. Retrieved 1819:. 2016-02-11 1816: 1807: 1792:Protothreads 1752: 1751:that of the 1748: 1734: 1722: 1714: 1702: 1690: 1640: 1509: 1486: 1470: 1458: 1449: 1439: 1429: 1424: 1413: 1351:Da Vinci JVM 1340: 1325: 1315: 1311: 1302: 1287: 1274: 1262: 1234: 1217: 1208: 1183: 1126:preprocessor 1082:concurrencpp 1062:Protothreads 1054:Simon Tatham 1051: 1047: 1011: 987:Protothreads 968: 960: 956:event-driven 948: 942: 933: 910: 894: 882: 624:Turbo Pascal 585: 522: 502: 488: 483: 479: 475: 472: 468: 467:produce 464: 460: 456: 452: 448: 444: 441: 437: 434: 433:consume 430: 427: 423: 420: 419:produce 416: 412: 404: 392: 377: 361:system calls 330: 320: 314: 309: 305: 303: 298: 294: 290: 287: 286:consume 283: 279: 275: 272: 271:produce 268: 264: 259: 254: 252: 243: 226:as one-shot 219: 217: 207: 203: 189: 177: 171: 160: 146: 141: 138: 97: 96: 81: 72: 57:by removing 44: 3228:Subroutines 3160:(2): 1–31. 2718:"Iterators" 2598:libdill.org 2283:Stack Abuse 2265:www.lua.org 2039:(9): 7–13. 1962:(2): 1–31. 1781:Async/await 1535:Open Swoole 1385:node-fibers 1316:input range 1267:project by 1110:- In 2010, 994:sigaltstack 898:stack-based 873:(since 8.6) 783:Coro module 781:(using the 745:(since 1.1) 648:(Since 2.0) 605:AngelScript 550:video games 546:Actor model 519:Common uses 486:dispatcher 349:parallelism 345:concurrency 297:to produce 282:to consume 240:Subroutines 122:event loops 106:subroutines 3217:Categories 3134:2011-01-26 3080:2016-06-27 2992:2021-06-08 2820:2022-11-28 2796:2022-11-28 2772:2022-11-28 2608:2019-10-21 2534:2013-09-06 2218:2018-06-18 1823:2023-01-10 1799:References 1514:backends. 1379:JavaScript 1366:Coroutines 1331:goroutines 1289:Cloroutine 971:call stack 904:, part of 877:urbiscript 728:JavaScript 577:integrand. 560:Generators 540:tail calls 509:tail calls 445:subroutine 407:trampoline 383:Generators 247:"yielding" 118:exceptions 98:Coroutines 75:April 2024 18:Coroutines 3162:CiteSeerX 3021:"RFC #31" 2749:Microsoft 2726:Microsoft 2594:"libdill" 1964:CiteSeerX 1908:0001-0782 1761:VAX MACRO 1705:Smalltalk 1699:Smalltalk 1540:Coroutine 1430:coroutine 1312:generator 1199:includes 1195:keyword. 1189:generator 1161:by Docker 1030:registers 923:or via a 851:Smalltalk 672:Dynamic C 622:(Borland 610:Ballerina 453:generator 431:generator 417:generator 396:iterators 357:switching 355:context ( 284:coroutine 269:coroutine 147:coroutine 126:iterators 59:excessive 3076:. Tcl.tk 2921:24 April 2495:Archived 2453:man7.org 2369:Archived 2055:20512767 1916:10559786 1858:Archived 1786:Pipeline 1775:See also 1741:MACRO-11 1621:Greenlet 1616:Eventlet 1603:PEP 0492 1601:syntax ( 1589:PEP 3156 1552:examples 1441:Modula-2 1436:Modula-2 1358:Javaflow 1241:Archived 1224:Archived 1219:Caliburn 1042:clobbers 983:Tom Duff 856:Squirrel 799:Picolisp 769:Modula-2 734:support. 697:GDScript 457:iterator 365:blocking 301:produce 3184:9918449 2916:Lua.org 2894:Lua.org 2431:"libco" 1986:9918449 1579:PEP 380 1569:PEP 342 1550:, many 1293:Clojure 1284:Clojure 1136:ScummVM 1132:ScummVM 1001:or the 952:locking 935:Threads 913:closure 774:Nemerle 708:Haskell 564:streams 369:mutexes 363:or any 333:threads 327:Threads 53:Please 45:use of 3182:  3164:  3124:571269 3122:  3112:  2839:go.dev 2815:go.dev 2791:go.dev 2767:go.dev 2336:  2146:Feb 2, 2094:11 May 2085:  2053:  2010:  1984:  1966:  1937:  1914:  1906:  1850:  1769:Assist 1745:PDP-11 1693:Scheme 1691:Since 1687:Scheme 1676:fibers 1661:fibers 1642:Racket 1637:Racket 1626:gevent 1610:Python 1608:Since 1595:Python 1585:Python 1575:Python 1565:Python 1559:Python 1544:Python 1524:Fibers 1489:Thread 1415:Kotlin 1410:Kotlin 1401:Since 1364:, and 1197:C# 5.0 1185:C# 2.0 1134:- The 1108:Mordor 939:fibers 883:Since 845:Simula 835:Scheme 830:Sather 809:Python 804:Prolog 793:HipHop 791:(with 779:Perl 5 743:Kotlin 687:Factor 677:Erlang 652:Chapel 620:Pascal 600:Aikido 398:, the 186:resume 3180:S2CID 3120:S2CID 2912:(PDF) 2857:(PDF) 2051:S2CID 1982:S2CID 1912:S2CID 1882:(PDF) 1861:(PDF) 1844:(PDF) 1757:VAXen 1599:await 1530:Amphp 1483:OCaml 1445:Wirth 1390:Fibjs 1308:Fiber 1256:Unity 1247:) by 1201:await 1193:yield 1173:Oat++ 1153:Clang 1092:boost 1075:C++20 999:POSIX 991:POSIX 759:Lucid 749:Limbo 738:Julia 732:await 657:ChucK 635:BLISS 538:with 507:with 465:start 461:start 442:yield 438:while 428:yield 424:while 400:yield 321:yield 310:yield 306:yield 295:yield 291:while 280:yield 276:while 255:yield 212:yield 182:yield 134:pipes 3110:ISBN 3042:2021 2923:2023 2414:(PS) 2334:ISBN 2148:2011 2096:2013 2083:ISBN 2008:ISBN 1935:ISBN 1904:ISSN 1848:ISBN 1771:09. 1759:(in 1753:next 1724:Vala 1719:Vala 1672:Ruby 1657:Ruby 1651:Ruby 1512:Raku 1505:Coro 1499:Perl 1461:Mono 1459:The 1455:Mono 1343:Java 1337:Java 1261:The 1254:The 1233:The 1216:The 1207:The 1159:elle 1112:Mozy 925:goto 840:Self 825:Ruby 820:Raku 764:ΞΌC++ 718:Icon 630:BETA 615:BCPL 532:goto 484:call 480:next 476:call 473:loop 435:loop 421:loop 299:call 288:loop 273:loop 184:and 132:and 108:for 100:are 3172:doi 3102:doi 2041:doi 1974:doi 1896:doi 1749:i.e 1518:PHP 1426:Lua 1421:Lua 1122:CO2 1069:C++ 1034:ABI 871:Tcl 789:PHP 754:Lua 662:CLU 640:C++ 469:var 449:var 413:var 265:var 61:or 3219:: 3178:. 3170:. 3158:31 3156:. 3118:. 3108:. 2942:10 2940:. 2914:. 2892:. 2837:. 2813:. 2789:. 2765:. 2747:. 2743:. 2724:. 2720:. 2631:^ 2596:. 2451:. 2433:. 2422:^ 2383:^ 2299:. 2281:. 2263:. 2192:. 2134:. 2049:. 2037:17 2035:. 2031:. 1994:^ 1980:. 1972:. 1960:31 1958:. 1910:. 1902:. 1890:. 1884:. 1856:. 1815:. 1605:). 1548:Go 1432:. 1360:, 1327:Go 1322:Go 1310:A 1180:C# 1024:, 847:67 723:Io 703:Go 682:F# 646:C# 594:. 556:). 482:d 455:β†’ 257:. 136:. 128:, 124:, 120:, 116:, 3186:. 3174:: 3137:. 3104:: 3083:. 3044:. 3023:. 3009:. 2995:. 2925:. 2896:. 2841:. 2823:. 2799:. 2775:. 2643:. 2611:. 2567:. 2552:. 2537:. 2455:. 2437:. 2342:. 2303:. 2267:. 2249:. 2235:. 2221:. 2196:. 2178:. 2164:. 2150:. 2114:" 2098:. 2043:: 2016:. 1988:. 1976:: 1943:. 1898:: 1892:6 1826:. 1581:) 1571:) 1368:. 1304:D 1299:D 1239:( 1222:( 1142:. 975:C 965:C 785:) 667:D 542:. 214:. 88:) 82:( 77:) 73:( 69:. 51:. 20:)

Index

Coroutines
external links
improve this article
excessive
inappropriate
footnote references
Learn how and when to remove this message
computer program
subroutines
cooperative multitasking
cooperative tasks
exceptions
event loops
iterators
infinite lists
pipes
Melvin Conway
assembly program
first-class objects
expressive power
continuations
"yielding"
multithreading
threads
cooperatively multitasked
preemptively multitasked
concurrency
parallelism
hard-realtime
switching

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.

↑