[gambit-list] Pushing events between C++ and Scheme + timers

Marc Feeley feeley at IRO.UMontreal.CA
Wed Dec 8 14:21:21 EST 2004


> Something I could do is set up two queues (lists?) in Scheme, one for
> incoming events and one for outgoing. My scheme code would then run in
> some sort of a thread, polling the incoming queue and posting events to
> the outgoing queue. C++ would poll the outgoing queue and post events to
> the incoming queue via a Scheme call. 
> 
> Writing Scheme bindings for the networking library and for SDL could be
> another option but I'd rather try to set up a thin C++ to Scheme
> interface layer first as it would let me focus on the application logic.

Are you willing to start a C thread for the Scheme code?  This would
decouple control between Scheme and C, allowing timers to be
implemented in Scheme with the I/O timeout mechanisms.  Then you need
two pipes between the C and Scheme worlds.  These pipes could be
actual OS pipes, sockets, or a new type of device (this would be more
efficient and portable, but require the implementation of a new device
in _os_io.c).

Marc


More information about the Gambit-list mailing list