This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: Using Guile with threads
- To: "Frederic Brunel" <brunel at mail dot dotcom dot fr>
- Subject: Re: Using Guile with threads
- From: Russell McManus <russe at ms dot com>
- Date: 01 Nov 1999 08:38:23 -0500
- Cc: <guile at sourceware dot cygnus dot com>
- References: <000201bf1c08$3f88a8a0$443d1bd4@tetsuo> <76yactkh5z.fsf@odie.lanl.gov> <000401bf245d$76ec0140$0b3d1bd4@tetsuo>
All access to the guile interpreter must live in just one thread. The
way to emulate multiple threads accessing the interpreter at the same
time is to use a 'guile-interpreter' thread that takes computation
requests off a mutex protected queue, and then signals the condition
variable associated with the request.
Pseudo code of guile thread:
* wait for data on input queue.
* process computation request.
* store result into request structure.
* signal condition variable on request structure.
* top.
Pseudo code of other thread:
* create request structure, with condition variable to wait on until
result is ready.
* put request structure onto input queue.
* signal guile thread that data is there
* wait on request condition variable.
You can have multiple threads putting data into the input queue, thus
emulating the desired behavior. I agree that it's too bad that guile
doesn't have real thread support :-(
I have some code which (not in working order) based on the above
ideas, which I wanted to put into the FAQ, but I haven't gotten to
it. I'll send it to you if you want. I hope this helps,
-russ
"Frederic Brunel" <brunel@mail.dotcom.fr> writes:
> First of all, I'm trying to use Guile in a small C++
> 3D engine. All I want is to launch a console
> (like the scrip-fu console of Gimp) in a thread and
> an OpenGL session in another.
> The two threads must have access to Guile. The
> console thread will evaluate scheme code to build
> new objects and put them in the 3D world (in real-time)
> and the other thread is the world main loop, its
> job is to update all 3D objects by calling scheme
> code to control them.
--
If I haven't seen further, it is by standing in the footsteps of giants.