Sven Panne <[EMAIL PROTECTED]> wrote,

> "Manuel M. T. Chakravarty" wrote:
> > [...]
> > The required synchronization could of course be programmed
> > using `Concurrent's semaphores, but with the disadvantage
> > that if we want to provide this thread-safety transparently
> > for user applications in a library, we have to define a
> > "new" IO monad on top of the standard one (to thread the
> > reference to the semaphore to all library calls).  As a
> > consequence, all standard IO operations would have to be
> > lifted to the new IO monad.[2]  [...]
> 
> I'm not sure if this is neccessary, because it is possible to have
> global (mutable!) variables via IORefs + unsafePerformIO:
> 
> \begin{UseHaskellLikeC}
> 
> blockingSem :: IORef QSem
> blockingSem = unsafePerformIO (newIORef =<< newQSem 1)
> 
> gtkMumbleFooBar :: ... -> IO ()
> gtkMumbleFooBar ... = do
>    ...
>    waitQSem =<< readIORef blockingSem
>    doObscureGTKStuff
>    ...
> 
> \end{UseHaskellLikeC}

Ok, this one is cool & dirty ;-)   And I think, it should do
in this case.  

Thanx,

Manuel

Reply via email to