[Haskell-cafe] One-shot? (was: Global variables and stuff)
Keean Schupke
k.schupke at imperial.ac.uk
Wed Nov 10 12:11:31 EST 2004
I have written a small library for supporting one-shot without using
unsfePerformIO...
The library uses SYSV semaphores under linux to make sure the functional
argument of
"once" is only ever run once. It uses the ProcessID as the key for the
semaphore, so will
even enforce the once-only property accross different Haskell threads.
Some semaphore
functions are also exported, allowing other constraints to be used (for
example, once
only over multiple processes by using a constant ID rather than the
processID.
I have attached the source for the library incase anyone is interested.
If people think
it is useful I could put it up on a website (let me know). Also attached
is an example,
which can be compiled with:
ghc -o test NamedSem.hs Test.hs -package posix
Keean.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: NamedSem.hs
Type: text/x-haskell
Size: 2299 bytes
Desc: not available
Url : http://www.haskell.org//pipermail/haskell-cafe/attachments/20041110/41611e69/NamedSem.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Test.hs
Type: text/x-haskell
Size: 176 bytes
Desc: not available
Url : http://www.haskell.org//pipermail/haskell-cafe/attachments/20041110/41611e69/Test.bin
More information about the Haskell-Cafe
mailing list