chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Chicken callbacks


From: Ivan Raikov
Subject: Re: [Chicken-users] Chicken callbacks
Date: Mon, 1 Jun 2015 08:55:12 -0700

Hello,

  You will need to define your Scheme procedure with define-external
and then you can pass it as a function pointer to C routines.
Your list of global events will need to be in static allocated memory
(object-evict and friends).
Check out section 'Callbacks' in the Chicken manual.  Examples of
define-external used for C callbacks can be found in e.g. the sundials
library, which is an interface to the SUNDIALS solvers written in C.

  -Ivan

On Sun, May 31, 2015 at 12:08 PM, chi <address@hidden> wrote:
> If you use a C library that requires callbacks, like libuv for instance, is it
> possible to write a procedure in chicken that will be guaranteed to return, as
> the C library requires? Like, by avoiding thread switching or call/cc or 
> something?
>
> I was thinking to sort of invert libuv, by using simple callbacks that only
> updated a global list of active event objects. The libuv main loop would 
> return
> after a single event came in, and the scheme code could handle the events by
> checking that active list, and not have to worry about whether they're inside 
> a
> persnickety C callback. Sort of like how epoll returns a list of active 
> events,
> and libuv covers that up by dispatching those events to callbacks, and then I
> would use those callbacks to ...create a list of active events. Would I have 
> to
> write those simple callbacks in C too? Could those simple C callbacks update a
> scheme "active event list" structure without getting longjmp'd? Or maybe the
> surrounding scheme would read a C structure "active" list?
>
> Come to think on it, epoll returns a list of active events, and doesn't IOCP
> also return a list of active events? I'm not much familiar with the Microsoft
> platform. I know Linux's async disk IO methods return a list of active events
> with no callbacks. (Then Glibc's AIO wraps them up in callbacks AND a thread
> pool -_-) Pretty sure kqueue doesn't use callbacks either. Most kernel
> developers are probably going to have a hard time doing anything with 
> callbacks
> I imagine, since such callbacks would violate the kernel/userspace separation.
> Almost as if callbacks were a horrible idea in general...
>
> If so, I wish there was a cross platform networking library that used each
> platforms "fast" event poller, and simply produced a unified interface for
> events produced, instead of wrapping it up in registering callbacks and all 
> that
> jazz. Can't think of a non-platform-specific events library that /doesn't/ use
> callbacks...
>
> _______________________________________________
> Chicken-users mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/chicken-users



reply via email to

[Prev in Thread] Current Thread [Next in Thread]