coroutine

Synchronizing thread communication?

Just for the heck of it I'm trying to emulate how JRuby generators work using threads in C#. Also, I'm fully aware that C# has built in support for yield return, I'm just toying around a bit. I guess it's some sort of poor mans coroutines by keeping multiple callstacks alive using threads. (even though none of the callstacks should exe...

Available Coroutine Libraries in Java

I would like to do some stuff in Java that would be clearer if written using concurrent routines, but for which full-on threads are serious overkill. The answer, of course, is the use of coroutines, but there doesn't appear to be any coroutine support in the standard Java libraries and a quick Google on it brings up tantalising hints he...

Implementing coroutines in Java

This question is related to my question on existing coroutine implementations in Java. If, as I suspect, it turns out that there is no full implementation of coroutines currently available in Java, what would be required to implement them? As I said in that question, I know about the following: You can implement "coroutines" as threa...

How can I create a parallel stack and run a coroutine on it?

Hey guys, In today's "Zneak's time-wasting adventures", I decided I should try to implement coroutines (I think that's how I should call them). I expect to have to use assembler, and probably some C if I want to make this actually useful for anything. Bear in mind that this is for educational purposes. Using an already built coroutine ...

Why doesn't this simple Lua coroutine work?

I have a very simple little piece of Lua code, which I wrote while teaching myself how coroutines work. I was fine until I got to coroutine.wrap, the spec states: coroutine.wrap (f) Creates a new coroutine, with body f. f must be a Lua function. Returns a function that resumes the coroutine each time it is called. Any arg...

Why do most object oriented languages not support coroutines?

I'm currently preparing for an exam. One of the question I found in an old exam is: "Why do most object oriented languages not support coroutines? (Hint: It's not because they support threads)" The problem is, that I can't find a good answer. Of course you don't need coroutines if you have object orientation, but it would still be very u...

Coroutine demo source

Here's an example of a program, where coroutines really help to simplify the algorithm - imho its hardly possible to implement otherwise. I also tried to choose a useful task for the demo - this utility converts a binary file to a sequence of A-Z symbols (and back), without any significant redundancy, and it has an ability to work with a...

How are coroutines implemented?

I have a question about coroutine implementation. I saw coroutine first on Lua and stackless-python. I could understand the concept of it, and how to use yield keyword, but I cannot figure out how it is implemented. Can I get some explanation about them? ...

Is it possible to implement coroutines using only LISP primitives?

First, I'm a LISP newbie. What I want to get is a cooperative micro-threading feature. And this can be gained with coroutine. As I know, Scheme supports coroutines via continuations. However, not all Scheme implementation may have continuations. If so, can I add a continuation feature with only LISP primitives? ...

Is there a safe way to use setjmp() and longjmp() in C++?

I was under the impression that using setjmp() and longjmp() in C++ was almost guaranteed to mess up the stack, since these functions don't perform unwinding like, say, exceptions do. This MSDN page, however, indicates that the Microsoft implementation can be told to invoke the destructors of local objects, which implies that careful use...

Objective-C Coroutine

Objective-C - how might I be able to create a objective-c coroutine? When I have a IBAction called by a button it freezes the app until the IBAction finishes retreiving data (from a web site). How might I have this run as a coroutine to the main app? Thanks, Christian Stewart ...

Abandoning coroutines

How bad is it in Lua 5.1 to never let a coroutine properly end? In other words, if a coroutine yields but I never resume it, does it leave a lot of state lying around until program completion? cor=coroutine.wrap(somefunc) while true do done=cor() if done then -- coroutine exited with "return true" break else -- corouti...

State machine in Ruby using Fibers?

hello, I'm trying to get a handle on the new Fiber class in Ruby 1.9 and I read that one of the more common applications for Fibers (and coroutines) is in state machines. Unfortunately my Fiber-fu isn't up to much, so I was hoping one of you could show me a simple statemachine example in Ruby using Fibers thanks :) ...

What's the advantage of stack-less Python's microthread than Lua's coroutine in state machine implementation for game?

Any advantage on stack-less python implentation than Lua's coroutine? What's the difference of them? ...