aboutsummaryrefslogtreecommitdiffhomepage
path: root/System/Posix/Semaphore.hsc
diff options
context:
space:
mode:
authorGravatar Simon Marlow <marlowsd@gmail.com>2009-09-08 14:25:36 +0000
committerGravatar Simon Marlow <marlowsd@gmail.com>2009-09-08 14:25:36 +0000
commitf084067857cabbc5d0a8f14ac5d2a4a1aee5e690 (patch)
treeaeee0399ff0d6ccbaee329be38815992293256fc /System/Posix/Semaphore.hsc
parent37e5c135b466f744a8ecdbc3f0b4bd9ef15c728c (diff)
Use Foreign.Concurrent for Haskell finalizers (#3473)
Diffstat (limited to 'System/Posix/Semaphore.hsc')
-rw-r--r--System/Posix/Semaphore.hsc10
1 files changed, 5 insertions, 5 deletions
diff --git a/System/Posix/Semaphore.hsc b/System/Posix/Semaphore.hsc
index c006b6f..a031b00 100644
--- a/System/Posix/Semaphore.hsc
+++ b/System/Posix/Semaphore.hsc
@@ -24,7 +24,8 @@ module System.Posix.Semaphore
#include <fcntl.h>
import Foreign.C
-import Foreign.ForeignPtr
+import Foreign.ForeignPtr hiding (newForeignPtr)
+import Foreign.Concurrent
import Foreign.Marshal
import Foreign.Ptr
import Foreign.Storable
@@ -51,11 +52,10 @@ semOpen name flags mode value =
semOpen' cname =
do sem <- throwErrnoPathIfNull "semOpen" name $
sem_open cname (toEnum cflags) mode (toEnum value)
- finalizer <- mkCallback (finalize sem)
- fptr <- newForeignPtr finalizer sem
+ fptr <- newForeignPtr sem (finalize sem)
return $ Semaphore fptr
- finalize sem _ = throwErrnoPathIfMinus1_ "semOpen" name $
- sem_close sem in
+ finalize sem = throwErrnoPathIfMinus1_ "semOpen" name $
+ sem_close sem in
withCAString name semOpen'
-- | Delete the semaphore with the given name.