|
| |
| | Coroutine - Wikipedia, the free encyclopedia |
 | | Coroutines are well-suited for implementing more familiar program components such as cooperative tasks, iterators, infinite lists, and pipes. |  | | In computer science, coroutines are program components that generalize subroutines to allow multiple entry points and suspending and resuming of execution at certain locations. |  | | Coroutines in which subsequent calls yield additional results are often known as generators. |
|
http://en.wikipedia.org/wiki/Coroutine
(1175 words)
|
|
| |
| | [No title] |
 | | Second, it may be viewed as a partition of a set of coroutines (objects) that exist at any moment of a computation into subsets and as the indication which transitions are possible and what are the conditions necessary to move a coroutine from one set (read: state) into another. |  | | Second, it is the instruction attach(c) which suspends the currently executed coroutine, and moves the processor to the object c where the execution is resumed at the last point of suspension. |  | | The system of coroutines we present here seems to be simpler, easier to understand and to implement efficiently than others known to us. |
|
http://aragorn.pb.bialystok.pl/~salwicki/progobi/coroutin.doc
(1834 words)
|
|
| |
| | PEP 342 -- Coroutines via Enhanced Generators |
 | | Coroutines are a natural way of expressing many algorithms, such as simulations, games, asynchronous I/O, and other forms of event- driven programming or co-operative multitasking. |  | | Also, generators cannot yield control while other functions are executing, unless those functions are themselves expressed as generators, and the outer generator is written to yield in response to values yielded by the inner generator. |  | | In effect, this example emulates simple tasklets as are used in Stackless Python, as long as you use a yield expression to invoke routines that would otherwise "block". |
|
http://www.python.org/dev/peps/pep-0342
(2727 words)
|
|
| |
| | Xalan-Java 2.7.0: Class CoroutineManager |
 | | The fact that only one of a group of coroutines is running at a time, and the control transfer between them is explicit, simplifies their possible interactions, and in some implementations permits them to be implemented more efficiently than general multitasking. |  | | Structuring it as two tasks connected by a queue may involve higher overhead (in systems which can optimize the coroutine metaphor), isn't necessarily as clear in intent, may have trouble handling cases where data flows in both directions, and may not handle some of the more complex cases where more than two coroutines are involved. |  | | Others rely on the fact that, since only one member of a coroutine set is running at a time and does not lose control until it chooses to do so, data structures may be directly shared between them with only minimal precautions. |
|
http://xml.apache.org/xalan-j/apidocs/org/apache/xml/dtm/ref/CoroutineManager.html
(1105 words)
|
|
| |
| | Squawks of the Parrot: What the heck is: a coroutine |
 | | With an operator to "create a coroutine object that will call subroutine X", and a resume operator, you get to choose whether an invokation is a recursive subroutine call or a new coroutine creation and resumption. |  | | Co-routines are definitely very powerful and often are used as iterators, tied to some data structure where re-invoking the coroutine walks through the structure a step, or generators, where each invocation of the coroutine returns the next value in a series. |  | | Our examples are really simple, but you could be nested ten or twenty levels of scope deep in a coroutine and still yield out--when you re-invoke the coroutine you'll be dropped back where you were, ten or twenty levels deep, with all your lexicals put back in place. |
|
http://www.sidhe.org/~dan/blog/archives/000178.html
(1848 words)
|
|
| |
| | [No title] |
 | | These two coroutine examples also show the concept of Python generators, which yield the next value of an array or binary tree as they are called. |  | | If one coroutine yields null and another yields a Leaf it means that the first tree has been fully traversed and the second tree still has branches or leaves to be visited, so the trees do not match. |  | | One of the real advantages of coroutines is that they can be aborted if the rest of the computation is deemed unnecessary. |
|
http://msdn.microsoft.com/msdnmag/issues/03/09/coroutinesinnet
(3930 words)
|
|
| |
| | 11 The Coroutines Module (coroutines.hhf) |
 | | In addition to these class procedures and methods, the coroutine package provides a coret procedure that is useful for returning from a coroutine to whomever "cocalled" the coroutine. |  | | The coroutine class provides three procedures and methods you can use to initialize a coroutine, transfer control between coroutines, and free up the storage associated with a coroutine when it completes execution. |  | | A good minimum value for a coroutine stack is between 256 and 1,024 bytes. |
|
http://webster.cs.ucr.edu/AsmTools/HLA/HLADoc/HLAstdlib/hlastdliba12.html
(940 words)
|
|
| |
| | Coroutine for Java |
 | | Coroutine also enables you to dynamically build callable wrappers around Java methods so external functions can call Java methods as if they are native functions. |  | | Note that we use the window's position and size to determine whether the current window in the callback is the one we are looking for. |  | | With Coroutine you don't need to write intermediate C++ wrappers. |
|
http://www.nevaobject.com/_docs/_coroutine/coroutine.htm
(5150 words)
|
|
| |
| | Coroutine.pm |
 | | Coroutines can be simulated with some success in languages without native support by using goto and label tricks. |  | | This module simulates the semi-coroutine (asymmetric coroutine / Python generator) language contruct in pure Perl. |  | | Calls a subroutine from a coroutine, where the subroutine itself can YIELD. |
|
http://www.math2.org/eulermb/pod/EulerMB/Coroutine.html
(672 words)
|
|
| |
| | Intro to System Software, Chapter 15 |
 | | This causes the computation which initiated the control transfer to be suspended, as a coroutine, and it causes the resumption of the computation to which control is transferred. |  | | This is because, when control is transferred to a coroutine, it must be possible to find the correct value of the program counter for that coroutine without knowledge of how control was most recently transferred away from that coroutine. |  | | coroutine shown in Figure 15.7 could have been improved by the use of read and write procedures which would encapsulate the references to the input and output queues and hide the small polling loops which await status changes in these queues. |
|
http://www.cs.uiowa.edu/~jones/syssoft/notes/15call.html
(5974 words)
|
|
| |
| | [No title] |
 | | When a work coroutine finds that it is increasing the value of countmin it release any coroutine waiting to increment its count. |  | | This program is most naturally implemented using both threads and coroutines but could be implemented using threads alone. |  | | The reply should be a sequence of ones and zeros encoding of x followed by minus one. |
|
http://www.cl.cam.ac.uk/users/mr/Tcobench/README
(1417 words)
|
|
| |
| | [No title] |
 | | The coroutine version is generally easier to use for debugging since the order of context switching is repeatable and the user need not worry about concurrent calls to C library routines. |  | | The first implements threads as coroutines in a single task. |  | | Out-of-kernel coroutine packages do, however, have many problems: - Scheduling is very difficult to do. |
|
http://www.cs.cmu.edu/afs/cs.cmu.edu/project/mach/public/doc/published/threads87.doc
(3896 words)
|
|
| |
| | Spark's Pensieve - Yield for Scheme |
 | | The intuitive way of looking at this is that it created two coroutines and advances both of them. |  | | Applies a return value from the values list to each of the coroutines and returns the new list of coroutines. |  | | Applies a return value to all of the coroutines and returns the new list of coroutines. |
|
http://www.thinkingms.com/pensieve/CommentView,guid,65223f21-a4f5-4eea-8d17-6c191cc48a02.aspx
(1951 words)
|
|
| |
| | Joe Duffy's Weblog |
 | | Enumerators are a very powerful feature, but unfortunately have one big drawback vis-à-vis their attempt at coroutines: you can yield only from one stack frame deep. |  | | I've posted before about how you might use C# enumerators to simulate coroutines. |  | | And of course, we can create a coroutine over a function that yields from functions deep in the call stack: |
|
http://www.bluebytesoftware.com/blog/PermaLink.aspx?guid=0f4f4c24-a11d-43ee-93ab-c5e1185005c3
(720 words)
|
|
| |
| | Coroutines in C |
 | | Included here is a C header file that implements this coroutine trick as a set of pre-defined macros. |  | | One is caller and the other is callee, true, but the visual structure of the functions are the same, and the insights they provide into their underlying algorithms are exactly as small as each other. |  | | In the caller, we have no problem; we code the original algorithm, pretty much exactly as written, and whenever it has (or needs) a character it calls the other function. |
|
http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html
(2668 words)
|
|
| |
| | C Coroutines |
 | | In short, you may think of coroutines as a very simple cooperative multitasking environment where the switch from one task to another is done explicitly by a function call. |  | | For a definition of the term coroutine see The Art of Computer Programming by Donald E. Knuth. |  | | Passing local data With coroutines there is a new way to generate dan gling references. |
|
http://www.goron.de/~froese/coro/coro.html
(1117 words)
|
|
| |
| | Callable Sort/Merge Library 1 of 3: cosort() |
 | | The coroutine supports the interactive exchange of information and data, making it more suitable for moving data incrementally between processing stages. |  | | CoSORT's coroutine sort library (and its thread-safe successor, MCS), best addresses integrated, or system level, data processing from a sort/merge perspective only. |  | | If you are interested in linking your programmatic inputs, other processes, and output requirements to additional, combinable transformations (like joins, aggregates, conversions, reformatting and so on), consider the sortcl_routine() API. |
|
http://www.iri.com/public/solutions/cosort/api_cosort.htm
(413 words)
|
|
| |
| | [No title] |
 | | Two Benchmark Tests for BCPL Style Coroutines This directory contains various implementions of two benchmark programs to test the efficiency of BCPL style coroutines when implemented in a variety of different languages. |  | | The benchmark: cobench This benchmark program creates a source coroutine, 500 copy coroutines and a sink coroutine. |  | | The BCPL Cintcode version of this cobench executes 257,569,294 Cintcode instructions changing coroutines 10,024,518 times. |
|
http://www.cl.cam.ac.uk/users/mr/Cobench/README
(679 words)
|
|
| |
| | CoRoutine Members |
 | | This method must be overriden in actual CoRoutine implementations, implementing the algorithm and code for the CoRoutine. |  | | Creates a shallow copy of the current Object. |  | | Obtain an array containing the rest of the values provided by the CoRoutine. |
|
http://www.vkarlsen.no/lvk.net/doc/LVK.CoRoutines.CoRoutineMembers.html
(253 words)
|
|
| |
| | ISO Modula-2 Language Reference |
 | | The created coroutine shall be initialized in such a way that when control is first transferred to that coroutine, the procedure given by the value of |  | | does not check if the given workspace overlaps with that of other coroutines; provided that a variable remains in existence until the end of program execution, the storage for that variable may be given to a coroutine for use as its workspace. |  | | it may be possible for a program to alter the values of coroutine variables or to affect control information such as procedure return addresses. |
|
http://www.excelsior-usa.com/doc/isom204.html
(7226 words)
|
|
| |
| | MAINSAIL Language Manual, Chapter 21 |
 | | Most simple algorithms are best phrased without the use of coroutines. |  | | In general, coroutines must transmit data to one another by means of outer or interface variables, since there is no way to pass parameters into or out of a coroutine using, e.g., |  | | If the exception is still not handled, the exception is simulated in the raisee coroutine's grandparent (all traces of the simulated exception in the parent are erased), and so forth. |
|
http://www.xidak.com/mainsail/documentation_set_1630_html/docset-MLANM-21.html
(1529 words)
|
|
| |
| | [No title] |
 | | This program simulates coroutine linkage with a big switch statement. |  | | The second uses multilinked data structures in a loopless way, so that each generation step performs a bounded number of operations to obtain the next element. |  | | Initially all the bits are~0; when it first returns false, it will have generated all legitimate bit patterns, ending with some nonzero pattern. |
|
http://www-cs-faculty.stanford.edu/~knuth/programs/koda-ruskey.w
(1411 words)
|
|
| |
| | Bees v0.5.0 API Documentation: Class Coroutine |
 | | The Coroutine matching the given event or a newly created Coroutine object if one doesn't already exist. |  | | - The BeesEvent that should be matched to a coroutine. |  | | The Coroutines unique identifier or INVALID_ID if the Coroutine has reached an error or completed state. |
|
http://www.cs.utah.edu/flux/janos/bees-0.5.0-doc/reference/bees/core/Coroutine.html
(280 words)
|
|
| |
| | Ulm's Coroutine Scheme |
 | | The coroutine structure contains information about the stack management registers (pointers to the activation record) and the program counter of the coroutine. |  | | The program counter of the coroutine is set to the instruction after the call of CRSPAWN. |  | | The main change is that coroutines declare themselves to be coroutines as illustrated by following example: |
|
http://www.mathematik.uni-ulm.de/oberon/0.5/articles/coroutines.html
(677 words)
|
|
| |
| | [No title] |
 | | RECOLLECTING COROUTINES ------------------------------------------------------------------------ An earlier installment of this column presented a mechanism for simulating coroutines with simple generators. |  | | David Mertz, Ph.D. Producer, Gnosis Software, Inc. February, 2002 A prior installment introduced a way of simulating full-fledged coroutines with generators and a simple scheduler. |  | | *Combining microthreads with coroutines*: In order to create a scheduler for weightless threads (microthreads), I removed the coroutine logic for "please branch to here." Doing that was not actually necessary. |
|
http://gnosis.cx/publish/programming/charming_python_b7.txt
(2127 words)
|
|
| |
| | Lua: 5.0 reference manual |
 | | returns 0 if there are no errors running the coroutine, or an error code (see 3.15). |  | | function only creates a new coroutine and returns a handle to it (an object of type thread); it does not start the coroutine execution. |  | | This library provides generic functions for string manipulation, such as finding and extracting substrings, and pattern matching. |
|
http://www.lua.org/manual/5.0/manual.html#BNF
(14426 words)
|
|
| |
| | Ice 9 - Coroutines Using Runqs |
 | | I use thunks (nullary procedures) and lists of thunks to represent strips, schedulable units of computation. |  | | On a transition from 0 to 1, the proxy adds a coroutine to the superior runq. |  | | By convention, the return value of a strip-thunk must either be another strip or the value |
|
http://theoryx5.uwinnipeg.ca/gnu/guile/in_9.html
(874 words)
|
|
| |
| | ASPN : Python Cookbook : Coroutines in Python |
 | | As an illustration, the __main__ part of the module starts 2000 coroutines which compute the values of a highly recursive function in a quasi-parallel fashion(1 GB windows machine). |  | | # self.running_coroutine maps coroutines to the position # in self.running_coroutines self.suspended = Set() # Coroutines which are not running. |  | | With coroutine I mean a construct as available, for example, in Simula 67 or Modula2. |
|
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/300019
(688 words)
|
|
| |
| | HP OpenVMS systems documentation |
 | | Coroutine calls between two routines are generally implemented as a set of JSB instructions within each routine. |  | | The coroutine initiator should then invoke the other routine with a JSB instruction. |  | | The compiler detects coroutine calls and flags them as errors. |
|
http://h71000.www7.hp.com/doc/82final/5601/5601pro_007.html
(3311 words)
|
|
| |
| | Citebase - Efficient coroutine generation of constrained Gray sequences |
 | | (More precisely, the directed graph of constraints is required to be cycle-free when it is regarded as an undirected graph.) If the coroutines are implemented carefully, they yield an algorithm that needs only a bounded amount of computation per bit change, thereby solving an open problem in the field of combinatorial pattern generation. |  | | [19] Leonard I. Vanek and Rudolf Marty, "Hierarchical coroutines: A method for improved program structure," Proceedings of the 4th International Conference on Software Engineering (Munich, 1979), 274-285. |  | | Lecture Notes in Computer Science 2635 (2004), 183-204 |
|
http://citebase.eprints.org/cgi-bin/citations?id=oai:arXiv.org:cs/0404058
(640 words)
|
|
| |
| | Coroutines in Python |
 | | E.g., # # in coroutine coA in coroutine coC in coroutine coB # x = co.tran(coC) co.tran(coB) co.tran(coA,12) # print x # 12 # # The data-passing feature is taken from Icon, and greatly cuts # the need to use global variables for inter-coroutine communication. |  | | Guido, this is one case where a "thread object" (e.g., thread.self()) would really help -- each thread here wants to remember _which_ coroutine it's implementing, and there's no clear way to do that (it's done here via an ad hoc mixture of local variables, class attributes, and storing info in a dict). |  | | # # Coroutine objects support these methods: # # handle =.create(func [, arg1, arg2,...]) # Creates a coroutine for an invocation of func(arg1, arg2,...), # and returns a handle ("name") for the coroutine so created. |
|
http://www.tismer.com/research/stackless/coroutines.tim.peters.html
(578 words)
|
|
| |
| | Coroutines in Lua Lambda the Ultimate |
 | | In Poplog not only can you create a coroutine from a procedure but also from another coroutine or simply from a snapshot of the current state. |  | | a coroutine can return values like a function call. |  | | Lua implements the concept of asymmetric coroutines, which are commonly denoted as semi-symmetric or semi-coroutines. |
|
http://lambda-the-ultimate.org/node/view/438
(476 words)
|
|
| |
| | [No title] |
 | | true is returned to the newly created coroutine which immediately starts execution. |  | | */ int start_coroutine(coroutine_ptr p); /* This function creates a new coroutine. |  | | This struct must be allocated before the creation of the coroutine. |
|
http://www.cs.utu.fi/staff/rlahdelma/Simul/COROUTIN.H
(259 words)
|
|
| |
| | Vita |
 | | A Simple Variant of the Boundary-Tag Algorithm for the Allocation of Coroutine Environments, |
|
http://www.drhanson.net/work/vita.html
(745 words)
|
|
| |
| | [No title] |
 | | Indeed, the algorithm I am proudest of is the coroutine sieve of Eratosthenes that I described at Cambridge in 1968, and which is now one of the chestnuts of parallel computing." (from e-mail communication) (37) "Evolution," p. |  | | I thought a lot about stream representations of algorithms. |  | | I had been much taken by Conway's idea of coroutines, which was published (in CACM?) around 1963, and was brought to high development by Dahl in Simula. |
|
http://www.columbia.edu/~rh120/ch001j.c11
(8764 words)
|
|
| |
| | Coroutines |
 | | It is initialized with the location of the first instruction of the coroutine. |  | | Coroutines are used in discrete simulation languages and, for some problems, provide a control structure that is more natural than the usual hierarchy of subprogram calls. |  | | From the description given of coroutines, it is apparent that coroutines should not be recursive. |
|
http://cs.wwc.edu/~aabyan/PLBook/book/node213.html
(201 words)
|
|
| |
| | A Portable C++ Library for Coroutine Sequencing (ResearchIndex) |
 | | The implementation of the library is described and examples of its use are given. |  | | The facilities of the library are based on the coroutine primitives provided by the programming language SIMULA. |  | | Please bear with us while we fix the problem. |
|
http://citeseer.ist.psu.edu/490590.html
(297 words)
|
|
| |
| | Coroutines |
 | | continuation) (next-coroutine value)))) (call/cc receiver))))) The following examples illustrate the use of coroutines (coroutine inorder (v) (letrec ((in (lambda (tree) (cond ((null? |  | | Define a coroutine: (coroutine name (value) body) Note that value is the initial value passed to the coroutine Using the coroutine: Call: (name arg) Resume: (resume new-coroutine arg) resume new-coroutine with arg; e.g. |
|
http://userwww.sfsu.edu/~levine/common/csc600/cs600/coroutine/coroutine.htm
(99 words)
|
|
| |
| | CoRoutine Class |
 | | Periodically the code can call upon the CoRoutine to yield a value and the CoRoutine will do so and continue executing. |  | | A CoRoutine is a special kind of function that will execute alongside the code that calls it. |  | | However, since the code is used like a CoRoutine, and does not outwardly have many signs that it is using a thread, I decided to keep the CoRoutine name for now. |
|
http://www.vkarlsen.no/lvk.net/doc/LVK.CoRoutines.CoRoutine.html
(219 words)
|
|
| |
| | jcalderone: Daddy, What Is A Coroutine? |
 | | It just has nothing to do with coroutines. |  | | The PEP suggests that it will allow coroutines to be implemented using a trampoline (with which, by the way, Guido doesn't even think anyone important will bother). |  | | Coroutines can be switched between regardless of their position in the call stack. |
|
http://jcalderone.livejournal.com/17608.html
(232 words)
|
|
| |
| | LtU Classic Archives |
 | | If the file size is 312586 bytes, then it has already been inflated and you just need to rename it to p160.ps. |  | | A nice example of efficiently implementing coroutines (using a single stack). |  | | Posted to general by Ehud Lamm on 6/9/03; 12:01:37 AM |
|
http://lambda-the-ultimate.org/classic/message7213.html
(333 words)
|
|
| |
| | Module Documentation - Coro 0.53 |
 | | Future versions of this function will allow result arguments. |  | | The coroutine to switch to when no other coroutine is running. |  | | The current coroutine (the last coroutine switched to). |
|
http://aspn.activestate.com/ASPN/CodeDoc/Coro/Coro.html
(551 words)
|
|
| |
| | Coroutine Pascal - OneLook Dictionary Search |
 | | Coroutine Pascal : Free On-line Dictionary of Computing [home, info] |  | | Tip: Click on the first link on a line below to go directly to a page where "Coroutine Pascal" is defined. |  | | We found one dictionary with English definitions that includes the word Coroutine Pascal: |
|
http://www.onelook.com/cgi-bin/cgiwrap/bware/dofind.cgi?word=Coroutine+Pascal
(72 words)
|
|
| |
| | forcing a coroutine.yield() - GameDev.Net Discussion Forums |
 | | You could make your Print function return a value that signals to a wrapping Lua function that it's time to yield though. |  | | Implement a 'wait_until' function that pushes a condition to the engine, and the engine calls yield when that condition is met. |  | | Personally I'd probably prefer to break up the script into several atomic functions that are called when necessary and require no coroutines though, but that's just because I prefer that sort of approach. |
|
http://gamedev.net/community/Forums/topic.asp?topic_id=326278&whichpage=1
(1124 words)
|
|
| |
| | Coroutine Synchronization In Avs - Klinker (ResearchIndex) |
 | | 1 AVS Network News (context) - Bethel, Coroutines - 1993 |  | | In many real-time applications, responding to user interaction or to real-time sensors (live camera input), finer-grained synchronization control is needed. |  | | This paper presents a token-based handshaking scheme which can be instantiated at runtime between any subgroups of modules and coroutines, allowing... |
|
http://citeseer.ist.psu.edu/262524.html
(313 words)
|
|
| |
| | [No title] |
 | | Date: Thu, 10 Mar 1994 00:54:44 GMT Lines: 83 (This might arrive twice on some sites -- sorry about that!) VSCM has built-in procedures for creating and managing coroutines. |  | | Strictly speaking it is not even necessary to have built-in coroutines since those can easily be implemented on top of call/cc. |  | | Even though I don't think it has already been done I'm pretty sure that it is easy to build engines out of those primitives. |
|
http://www.cs.cmu.edu/Groups/AI/util/lang/scheme/impl/vscm/notes.txt
(254 words)
|
|
| |
| | Bees v0.5.0 API Documentation: Uses of Class bees.core.Coroutine |
 | | A ResponderCoroutine is a Coroutine that automatically repeats state transitions to a StateResponder specified in the Constructor. |  | | Methods in bees.core with parameters of type Coroutine |  | | Constructors in bees.core with parameters of type Coroutine |
|
http://www.cs.utah.edu/flux/janos/bees-0.5.0-doc/reference/bees/core/class-use/Coroutine.html
(202 words)
|
|
| |
| | LUA: about coroutine and yield - GameDev.Net Discussion Forums |
 | | You say there's a 'problem' running the coroutine line, but without saying what the problem is. Can't help there. |  | | Unlike Python, the function doesn't automatically become a coroutine just because you use 'yield' inside it. |  | | Posted - 12/24/2004 9:27:02 AM Well, in that case, it implies the problem is with your PrintString function, or how you're calling it, as you're seeing the issue before the coroutine even starts. |
|
http://gamedev.net/community/forums/topic.asp?topic_id=290303&whichpage=1
(295 words)
|
|
| |
| | freshmeat.net: Project details for Portable Coroutine Library |
 | | This is a Portable Coroutine Library implementation written in ANSI C. Coroutines can be used to implement cooperative threading among many tasks without overloading the OS with threads/processes. |  | | Since context switch between coroutines is very fast, certain applications might have performance gain in using this type of threading. |  | | OSI Approved :: GNU General Public License (GPL) |
|
http://freshmeat.net/releases/118014
(139 words)
|
|
|