Permalink
Browse files

Update to 0MQ version 2.0.7 (beta) API.

This commit introduces breaking changes to match 0MQ's API:

- P2P is renamed to Pair
- init now takes only one parameter (ioThreads)
- The low watermark socket option is gone
  • Loading branch information...
1 parent 428ed0b commit f92fa2010855bced959d13fdc74ac685df4995d6 Toralf Wittner committed Jun 12, 2010
Showing with 25 additions and 36 deletions.
  1. +5 −0 .gitignore
  2. +2 −2 README
  3. +8 −20 src/System/ZMQ.hs
  4. +2 −6 src/System/ZMQ/Base.hsc
  5. +1 −1 test/display.hs
  6. +1 −1 test/perf/local_lat.hs
  7. +1 −1 test/perf/local_thr.hs
  8. +1 −1 test/perf/remote_lat.hs
  9. +1 −1 test/perf/remote_thr.hs
  10. +1 −1 test/poll.hs
  11. +1 −1 test/prompt.hs
  12. +1 −1 zeromq-haskell.cabal
View
@@ -0,0 +1,5 @@
+*.swp
+*.hi
+*.o
+dist/
+
View
4 README
@@ -3,10 +3,10 @@ This library provides Haskell bindings to zeromq (http://zeromq.org).
· Current status
-Version 0.2.x - This software currently has *alpha* status, i.e. it had
+Version 0.3.x - This software currently has *alpha* status, i.e. it had
only seen very limited testing and changes to its API might happen.
-This software was developed and tested on Linux 2.6.31 with GHC-6.12.1
+This software was developed and tested on Linux 2.6.32 with GHC-6.12.3
using the current git HEAD of zeromq2 (http://github.com/sustrik/zeromq2).
View
@@ -22,7 +22,7 @@ module System.ZMQ (
Poll(..),
PollEvent(..),
- P2P(..),
+ Pair(..),
Pub(..),
Sub(..),
Req(..),
@@ -86,10 +86,10 @@ class SType a where
-- | Socket to communicate with a single peer. Allows for only a
-- single connect or a single bind. There's no message routing
--- or message filtering involved. /Compatible peer sockets/: 'P2P'.
-data P2P = P2P
-instance SType P2P where
- zmqSocketType = const p2p
+-- or message filtering involved. /Compatible peer sockets/: 'Pair'.
+data Pair = Pair
+instance SType Pair where
+ zmqSocketType = const pair
-- | Socket to distribute data. 'receive' function is not
-- implemented for this socket type. Messages are distributed in
@@ -172,13 +172,6 @@ instance SubsType Sub
-- of the pipe.
-- /Default/: 0
--
--- [@LowWM@] Low watermark makes sense only if high watermark is
--- defined (i.e. is non-zero). When the emergency state is
--- reached when messages overflow the pipe, the emergency lasts
--- at most till the size of the pipe decreases to low watermark.
--- Normal state is resumed at that point.
--- /Default/: 0
---
-- [@Swap@] Swap allows the pipe to exceed high watermark. However,
-- the data are written to the disk rather than held in the memory.
-- Until high watermark is exceeded there is no disk activity involved
@@ -236,7 +229,6 @@ instance SubsType Sub
--
data SocketOption =
HighWM Int64 -- ^ ZMQ_HWM
- | LowWM Int64 -- ^ ZMQ_LWM
| Swap Int64 -- ^ ZMQ_SWAP
| Affinity Int64 -- ^ ZMQ_AFFINITY
| Identity String -- ^ ZMQ_IDENTITY
@@ -270,12 +262,9 @@ data Poll =
| F Fd PollEvent
-- | Initialize a 0MQ context (cf. zmq_init for details).
-init :: Size -> Size -> Bool -> IO Context
-init appThreads ioThreads doPoll = do
- c <- throwErrnoIfNull "init" $
- c_zmq_init (fromIntegral appThreads)
- (fromIntegral ioThreads)
- (if doPoll then usePoll else 0)
+init :: Size -> IO Context
+init ioThreads = do
+ c <- throwErrnoIfNull "init" $ c_zmq_init (fromIntegral ioThreads)
return (Context c)
-- | Terminate 0MQ context (cf. zmq_term).
@@ -300,7 +289,6 @@ close = throwErrnoIfMinus1_ "close" . c_zmq_close . sock
-- functions.
setOption :: Socket a -> SocketOption -> IO ()
setOption s (HighWM o) = setIntOpt s highWM o
-setOption s (LowWM o) = setIntOpt s lowWM o
setOption s (Swap o) = setIntOpt s swap o
setOption s (Affinity o) = setIntOpt s affinity o
setOption s (Identity o) = setStrOpt s identity o
View
@@ -47,9 +47,6 @@ instance Storable ZMQPoll where
#{poke zmq_pollitem_t, events} p e
#{poke zmq_pollitem_t, revents} p re
-usePoll :: CInt
-usePoll = #const ZMQ_POLL
-
type ZMQMsgPtr = Ptr ZMQMsg
type ZMQCtx = Ptr ()
type ZMQSocket = Ptr ()
@@ -60,7 +57,7 @@ type ZMQPollPtr = Ptr ZMQPoll
newtype ZMQSocketType = ZMQSocketType { typeVal :: CInt } deriving (Eq, Ord)
#{enum ZMQSocketType, ZMQSocketType,
- p2p = ZMQ_P2P,
+ pair = ZMQ_PAIR,
pub = ZMQ_PUB,
sub = ZMQ_SUB,
request = ZMQ_REQ,
@@ -75,7 +72,6 @@ newtype ZMQOption = ZMQOption { optVal :: CInt } deriving (Eq, Ord)
#{enum ZMQOption, ZMQOption,
highWM = ZMQ_HWM,
- lowWM = ZMQ_LWM,
swap = ZMQ_SWAP,
affinity = ZMQ_AFFINITY,
identity = ZMQ_IDENTITY,
@@ -105,7 +101,7 @@ newtype ZMQPollEvent = ZMQPollEvent { pollVal :: CShort } deriving (Eq, Ord)
-- general initialization
foreign import ccall unsafe "zmq.h zmq_init"
- c_zmq_init :: CInt -> CInt -> CInt -> IO ZMQCtx
+ c_zmq_init :: CInt -> IO ZMQCtx
foreign import ccall unsafe "zmq.h zmq_term"
c_zmq_term :: ZMQCtx -> IO CInt
View
@@ -12,7 +12,7 @@ main = do
hPutStrLn stderr "usage: display <address>"
exitFailure
let addr = head args
- c <- ZMQ.init 1 1 False
+ c <- ZMQ.init 1
s <- ZMQ.socket c ZMQ.Sub
ZMQ.subscribe s ""
ZMQ.connect s addr
View
@@ -14,7 +14,7 @@ main = do
let bindTo = args !! 0
size = read $ args !! 1
rounds = read $ args !! 2
- c <- ZMQ.init 1 1 False
+ c <- ZMQ.init 1
s <- ZMQ.socket c ZMQ.Rep
ZMQ.bind s bindTo
loop s rounds size
View
@@ -16,7 +16,7 @@ main = do
let bindTo = args !! 0
size = read $ args !! 1 :: Int
count = read $ args !! 2 :: Int
- c <- ZMQ.init 1 1 False
+ c <- ZMQ.init 1
s <- ZMQ.socket c ZMQ.Sub
ZMQ.subscribe s ""
ZMQ.bind s bindTo
View
@@ -16,7 +16,7 @@ main = do
size = read $ args !! 1
rounds = read $ args !! 2
message = SB.replicate size 0x65
- c <- ZMQ.init 1 1 False
+ c <- ZMQ.init 1
s <- ZMQ.socket c ZMQ.Req
ZMQ.connect s connTo
start <- getCurrentTime
View
@@ -16,7 +16,7 @@ main = do
size = read $ args !! 1
count = read $ args !! 2
message = SB.replicate size 0x65
- c <- ZMQ.init 1 1 False
+ c <- ZMQ.init 1
s <- ZMQ.socket c ZMQ.Pub
ZMQ.connect s connTo
replicateM_ count $ ZMQ.send s message []
View
@@ -12,7 +12,7 @@ main = do
when (length args /= 1) $ do
hPutStrLn stderr usage
exitFailure
- c <- ZMQ.init 1 1 True
+ c <- ZMQ.init 1
s <- ZMQ.socket c ZMQ.Rep
let bindTo = head args
toPoll = [ZMQ.S s ZMQ.In]
View
@@ -16,7 +16,7 @@ main = do
exitFailure
let addr = args !! 0
name = SB.append (SB.fromString $ args !! 1) ": "
- c <- ZMQ.init 1 1 False
+ c <- ZMQ.init 1
s <- ZMQ.socket c ZMQ.Pub
ZMQ.connect s addr
forever $ do
View
@@ -1,5 +1,5 @@
name: zeromq-haskell
-version: 0.2.2
+version: 0.3
synopsis: bindings to zeromq
description: Bindings to zeromq (http://zeromq.org)
category: System, FFI

0 comments on commit f92fa20

Please sign in to comment.