
On Tuesday 17 July 2007 12:27:38 Andrea Rossato wrote:
Hi,
today I added XEvents handling to xmobar, a status bar you should know I'm writing.
Now, this is more difficult of what I first thought, since xmobar makes heavy use of Haskell threads.
Since we need to call XNextEvent, it seems, as far as I can understand, that this is going to block every other Haskell threads, unless the threaded RTS is used and/or (?) forkOS (which requires anyway the threaded RTS) is used instead of forkIO.
Here is the relevant source from X11: foreign import ccall safe "HsXlib.h XNextEvent" nextEvent :: Display -> XEventPtr -> IO () The "safe" bit means that the FFI call will run in it's own OS thread -- it shouldn't block any Haskell threads. However, I believe that Xlib has internal locking that will cause XNextEvent to block all other Xlib calls. If forkOS changes the behavior here, we most likely have a mismarked "unsafe" function in X11.
While this is working fine on my system, I have a system with an old Xorg build (I cannot compile X11-1.2.2 and X11-extras on that machine), which seem to block all threads no matter what I do. This is not a valuable test for me, so I need testers to confirm or refute my personal test.
I believe this is XNextEvent blocking other threads. I've got an idea for a solution, expect another email shortly :). Cheers, Spencer Janssen