ide-backend-common-0.10.0: Shared library used be ide-backend and ide-backend-server

Safe HaskellNone
LanguageHaskell2010

IdeSession.Util.BlockingOps

Contents

Description

Blocking operations such as

readMVar v

may throw an exception such as

thread blocked indefinitely in an MVar operation

Unfortunately, this exception does not give any information of _where_ in the code we are blocked indefinitely. Compiling with profiling info and running with +RTC -xc can address this to some extent, but (1) it requires that all profiling libraries are installed and (2) when we are running multithreaded code the resulting stack trace is often difficult to read (and still does not include line numbers). With this module you can replace the above code with

$readMVar v

and the exception that will be thrown is

YourModule:lineNumber: thread blocked indefinitely in an MVar operation

which is a lot more informative. When the CPP flag DEBUGGING is turned off then $readMVar just turns into readMVar.

NOTE: The type of the exception changes when using DEBUGGING mode -- in order to be able to add the line number, all exceptions are turned into IOExceptions.

Synopsis

Generic debugging utilities

mapExceptionIO :: (Exception e1, Exception e2) => (e1 -> e2) -> IO a -> IO a Source

Blocking MVar ops

Same for strict MVars

Blocking Chan ops

Blocking Async ops