Fusing event loops is always tricky, but if you have the option of
exposing individual file descriptors to Racket, then `ffi/unsafe/port`
is probably the way to go. You can turn a file descriptor into an event
using `unsafe-file-descriptor->semaphore` or `unsafe-fd->evt`, and then
you can block on a set using `sync`, etc.

Matthew

At Mon, 3 Aug 2020 23:31:20 -0700 (PDT), Robert D Kocisko wrote:
> I have an existing c++ app that is entirely event-loop driven with epoll 
> and I am trying to figure out how to integrate Racket in the same thread 
> and allow the existing code to work as-is.  I have read the docs about the 
> C api and the FFI but so far a straightforward and clean option is not 
> apparent to me.  The 'embedding' examples that I see appear rather opaque 
> to me and at best seem to be geared towards an external loop based on 
> select() rather than epoll(), so I'm assuming that the more straightforward 
> approach would be to add the existing event handlers onto Racket's event 
> system.  To that end, it seems there should be a way to register the fd's 
> of interest with Racket and receive a callback when they are read-ready but 
> I can't see a way to do that.  For example, how would I maintain a list of 
> fds to pass to (sync) if I went that route?  Or if it's better to work it 
> the other way, how would I call (sync) from c code and apply the list of 
> fds to it?  I vaguely can see a way towards it but it seems at best super 
> inefficient.  Any thoughts or suggestions would be greatly appreciated!
> 
> Thanks,
> Bob Kocisko
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/46fb3804-396c-4921-849f-71fe5a6f
> ac7ao%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/20200804080838.2d0%40sirmail.smtps.cs.utah.edu.

Reply via email to