Prevent duplication of unsafePerformIO on a multiprocessor
authorSimon Marlow <simonmar@microsoft.com>
Tue, 6 Mar 2007 14:54:24 +0000 (14:54 +0000)
committerSimon Marlow <simonmar@microsoft.com>
Tue, 6 Mar 2007 14:54:24 +0000 (14:54 +0000)
commita8277460885b562bb9cbd75e3756ba439230c361
tree7cffd6e6e1b16191c87fd2e4dcac33f80733e51b
parent4078a951d6870205aad8935b7c794bab08060816
Prevent duplication of unsafePerformIO on a multiprocessor
Fixes #986.  The idea is to add a new operation

  noDuplicate :: IO ()

it is guaranteed that if two threads have executed noDuplicate, then
they are not duplicating any computation.

We now provide two new unsafe operations:

unsafeDupablePerformIO    :: IO a -> a
unsafeDupableInterleaveIO :: IO a -> IO a

which are equivalent to the old unsafePerformIO and unsafeInterleaveIO
respectively.  The new versions of these functions are defined as:

unsafePerformIO    m = unsafeDupablePerformIO (noDuplicate >> m)
unsafeInterleaveIO m = unsafeDupableInterleaveIO (noDuplicate >> m)
GHC/IOBase.lhs