Skip navigation.
 
mlRe: Any actor or coroutine implementations for Cocoa?
FROM : Jens Alfke
DATE : Wed Apr 30 23:37:05 2008

On 30 Apr '08, at 12:35 PM, Michael Ash wrote:

> This doesn't work because you can have multiple sheets which get
> dismissed out of order.
> For example, method X shows sheet A, method Y shows sheet B, user
> dismisses sheet A. Now you need to return back to method X but method
> Y is still on the call stack.


That's what would happen without coroutines. But with coroutines it's 
no problem, because X and Y aren't on the same call stack:

Coroutine 1 is running:
   ...
   method X calls runSheet(A)
   runSheet displays the sheet, then blocks and transfers control
Now coroutine 2 is running:
   ...
   method Y calls runSheet(B)
   runSheet displays the sheet, then blocks and transfers control
Main coroutine is running:
   ...events being handled...
   User clicks on OK button in sheet A
   Main coroutine wakes up coroutine 1
Coroutine 1 is running:
   sheet goes away, runSheet(A) returns
   back to method X
   ...

The main coroutine would handle the runloop and events as usual. But 
it would respond to events by messaging their associated coroutines/
actors.

—Jens

PS: I just updated the coroutine library. I rewrote the underpinnings 
to make them simpler, and added a call/yield style interface similar 
to Ruby's and Lua's.

Related mailsAuthorDate
mlAny actor or coroutine implementations for Cocoa? Jens Alfke Apr 29, 19:04
mlRe: Any actor or coroutine implementations for Cocoa? Jim Roepcke Apr 30, 00:55
mlRe: Any actor or coroutine implementations for Cocoa? Jens Alfke Apr 30, 02:26
mlRe: Any actor or coroutine implementations for Cocoa? Michael Ash Apr 30, 04:16
mlRe: Any actor or coroutine implementations for Cocoa? Jens Alfke Apr 30, 18:18
mlRe: Any actor or coroutine implementations for Cocoa? Michael Ash Apr 30, 21:35
mlRe: Any actor or coroutine implementations for Cocoa? Jens Alfke Apr 30, 23:37
mlRe: Any actor or coroutine implementations for Cocoa? Michael Ash May 1, 00:35