On 12/28/05, Bradley Lucier lucier@math.purdue.edu wrote:
Is there any way to add POLLs to C code? There's a C library I'd like to link to a program, but one C routine could possibly take seconds or minutes to run, and Gambit disables interrupts except through POLLs.
You mean that you want an external library to be able to wait on a file descriptor (e.g. using select/poll)? (Speaking about "disabling interrupts" is confusing. Gambit is a user-land process and cannot disable interrupts)
You need to hook into Gambit's main I/O loop. The code to do this is a little confusing because of the need to work across platforms, but you can find it. When the C object is linked into the Gambit code it can access Gambit's functions for manipulating the set of file descriptors to wait on. You'll need to pull in some of Gambit's internal headers, but it'll work.
Also; a few months ago I posted a patch to Beta 14 which changed the event loop to use libevent[1]. Your C code can then then use libevent as normal (except that it shouldn't call the init function) and everything will work perfectly.
[1] http://www.monkey.org/~provos/libevent/
AGL
-- Adam Langley agl@imperialviolet.org http://www.imperialviolet.org 650-283-9641