views:

175

answers:

3

I am responsible for a Windows application that loads up plugin "script" dll's written in c++.

The application exposes an API based on Win32 fibers to allow the c++ 'scripts' in the plugin dlls to use 'yield' and 'resume' type calls - essentially co-routines - to sequence the dependencies in the scripts without resorting to an asynchronous event architecture.

Now, I am looking at porting the app to Mac and or Linux, and the option of using a framework like Qt has come up.

Qt however seems only to support proper asynchronous threads, not lightweight synchronous threading primitives similar to Win32 fibers.

Is there a Win32 Fibera analog on Cocoa, or in a crossplatform framework like Qt?

A: 

I don't know about Cocoa, but in Qt you don't have support for fibers.

Cătălin Pitiș
A: 

There's nothing in Qt. However, there are existing coroutine libraries, and it's not that hard to write a Qt-style wrapper which uses fibers on Windows and setjmp/longjmp on POSIX.

e.g., here is an implementation of coroutines on POSIX in a nice wrapper class.

Intransigent Parsnip
A: 

Maybe you already found a decent solution but if not, (even though I haven't tried it) I think that Boost might be your friend:

http://www.crystalclearsoftware.com/soc/coroutine/

Adam