I've managed to compile (without errors) fluidsynth library that uses pthreads in old version and glib gthreads in newer version. However, in swf I get runtime errors Undefined sym: _pthread_attr_init
and Undefined sym: _g_thread_init
respectively.
Is this dead end as far as threading goes, or there's a way to make this work? (Or am I skipping something in the final linking phase?)
In case of gthreads, this doc mentions custom thread implementations:
The threading system is initialized with g_thread_init(), which takes an optional custom thread implementation or NULL for the default implementation.
I understand that alchemy doesn't support native threads, but could some fake green thread implementation be used for this purpose?
Since the Flash Player isn't threaded, your Alchemy C code can't be threaded. However, you may be able to work around it using the 'green threading' in Alchemy.
When you call a function exposed via AS3_FunctionAsync, it will suspend itself whenever flyield is called, allowing the other code to run, and then will resume 'later'.
I don't think there's any reason why your AS3 code couldn't call into two or more AS3_FunctionAsync-wrapped functions at the same time. Since your code is thread-safe is will probably just work. Note that you will have to put flyields all throughout your code in order to make it play nice (this is very much like the 'cooperative multitasking' of old OSes).
Anyway its worth a shot.