Thanks Adam. It took me some time to realize what you recognized immediately - xptr is useless. Instead I now bind the additional value which might be provided on event creation in a closure since the C code never has to deal with it.
And yes, there are many functions missing. For now I just need the event notification to detect file descritor (or socket) changes. Regarding your remark, that the RTS multiplexes IO already I am usure how this works out in practice. The reason I write this wrapper is that I want a network server which can handle thousands of connections. And to not require a permanent thread for each I would like to use something like select in C or Selector in Java. I haven't found something like this in Haskell, hence the libevent wrapper. If you have any information how to write something like this without this wrapper I would be more than happy. Finally the code still leaks FunPtrs as so far I never free them and honestly I don't know when to do this. Any ideas? For reference I have attached a newer version of the wrapper code (removed the TimeVal stuff since I don't need it). Thanks again, Levi On Fri, Jul 25, 2008 at 7:21 PM, Adam Langley <[EMAIL PROTECTED]> wrote: > 2008/7/23 Levi Greenspan <[EMAIL PROTECTED]>: >> I would be grateful for any advices, hints or comments. And I really >> look forward to the FFI section in the "Real World Haskell" book. > > Generally it looks pretty good. I think I'm missing some C code > (function "wrapper"). However, libevent is an odd choice to wrap. The > RTS already multiplexes IO for Haskell programs. In order not to block > the RTS, the libevent using code would have to be in its own kernel > thread. > > Really, the RTS needs to be ported to libevent rather than an FFI wrapping. > > For your specific problem, I see you're allocating xptr, but I don't > see that you're ever poking a value into it. Indeed, I can't see that > createEvent ever uses 'x'. > > Hope that helps. > > > > > AGL > > -- > Adam Langley [EMAIL PROTECTED] http://www.imperialviolet.org >
hsevent.hsc
Description: Binary data
_______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
