This is the mail archive of the libffi-discuss@sourceware.org mailing list for the libffi project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Using LibFFI along with threads


Hi Tom,

That's exactly what I want. PLT Scheme (DrScheme,MzScheme)
doesn't do OS threads. In real life this means that a call to a
native C function will block your entire scheme language
including all "threads" in scheme.

Imagin a long database query blocking all your threads, or
a inserter thread doing inserts on a database, blocking your
entire user interface.

What I want is to do a "non blocking" call to a C function, by
starting the C function in an OS thread and let the current scheme
thread wait for the result, while allowing other scheme threads
to run. I've done this trick already in the past, but without the
FFI. However, it needs a littlebit of C code that must be compiled,
and the goal of using the ffi is to allow for native C bindings
without the need to compile glue code.

I've looked into the foreign code of PLT Scheme yesterday and I
think it is actually extremely easy to allow for a non blocking
ffi call, that only blocks the current scheme thread, but no others.

Maybe I'll propose a small code change in the foreign code of
PLT Scheme.

--Hans


Op 17/7/2007 schreef "Tom Tromey" <tromey@redhat.com>:

>>>>>> "Hans" == Hans Oesterholt-Dijkema <hdnews@gawab.com> writes:
>
>Hans> Would it be possible to create an FFI object using libffi
>Hans> that is called from within a thread?
>
>I started looking at the source, but I think it would be simpler if
>you explained what you're trying to do.
>
>If you want to make a call via libffi and have the called function
>make a new thread, then make the real ffi call in that new thread --
>sure, this is possible.  You can pass CIFs and argument arrays around
>quite easily.
>
>Tom
>
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]