Skip to content
This repository has been archived by the owner on Apr 4, 2018. It is now read-only.

Commit

Permalink
Remove flush and NoFlush to match 0MQ API change.
Browse files Browse the repository at this point in the history
  • Loading branch information
Toralf Wittner committed Mar 18, 2010
1 parent 17bfaf0 commit 428ed0b
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 25 deletions.
3 changes: 1 addition & 2 deletions README
Expand Up @@ -3,7 +3,7 @@ This library provides Haskell bindings to zeromq (http://zeromq.org).

· Current status

Version 0.2 - This software currently has *alpha* status, i.e. it had
Version 0.2.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
Expand Down Expand Up @@ -31,7 +31,6 @@ The API mostly follows 0MQ's. Public functions are:
- connect
- send
- send'
- flush
- receive
- poll

Expand Down
18 changes: 1 addition & 17 deletions src/System/ZMQ.hs
Expand Up @@ -44,7 +44,6 @@ module System.ZMQ (
connect,
send,
send',
flush,
receive,

poll
Expand Down Expand Up @@ -253,17 +252,7 @@ data SocketOption =
-- [@NoBlock@] Send operation should be performed in non-blocking mode.
-- If it cannot be performed immediatley an error will be thrown (errno
-- is set to EAGAIN).
--
-- [@NoFlush@] 'send' should not flush the message downstream immediately,
-- instead it should batch messages send with 'NoFlush' and really send them
-- only when 'flush' is invoked. zmq_send(3) states: \"This is an optimisation
-- for cases where several messages are sent in a single business transaction.
-- However, the effect is measurable only in extremely high-perf scenarios
-- (million messages a second or so). If that's not your case, use standard
-- flushing send instead.\"
data Flag =
NoBlock -- ^ ZMQ_NOBLOCK
| NoFlush -- ^ ZMQ_NOFLUSH
data Flag = NoBlock -- ^ ZMQ_NOBLOCK
deriving (Eq, Ord, Show)

-- | The events to wait for in poll (cf. man zmq_poll)
Expand Down Expand Up @@ -351,10 +340,6 @@ send' :: Socket a -> LB.ByteString -> [Flag] -> IO ()
send' (Socket s) val fls = bracket (messageOfLazy val) messageClose $ \m ->
throwErrnoIfMinus1_ "send'" $ c_zmq_send s (msgPtr m) (combine fls)

-- | Flush the given socket (useful for 'send's with 'NoFlush').
flush :: Socket a -> IO ()
flush = throwErrnoIfMinus1_ "flush" . c_zmq_flush . sock

-- | Receive a 'ByteString' from socket (zmq_recv).
receive :: Socket a -> [Flag] -> IO (SB.ByteString)
receive (Socket s) fls = bracket messageInit messageClose $ \m -> do
Expand Down Expand Up @@ -460,7 +445,6 @@ setStrOpt (Socket s) (ZMQOption o) str = throwErrnoIfMinus1_ "setStrOpt" $

toZMQFlag :: Flag -> ZMQFlag
toZMQFlag NoBlock = noBlock
toZMQFlag NoFlush = noFlush

combine :: [Flag] -> CInt
combine = fromIntegral . foldr ((.|.) . flagVal . toZMQFlag) 0
Expand Down
6 changes: 1 addition & 5 deletions src/System/ZMQ/Base.hsc
Expand Up @@ -91,8 +91,7 @@ newtype ZMQOption = ZMQOption { optVal :: CInt } deriving (Eq, Ord)
newtype ZMQFlag = ZMQFlag { flagVal :: CInt } deriving (Eq, Ord)

#{enum ZMQFlag, ZMQFlag,
noBlock = ZMQ_NOBLOCK,
noFlush = ZMQ_NOFLUSH
noBlock = ZMQ_NOBLOCK
}

newtype ZMQPollEvent = ZMQPollEvent { pollVal :: CShort } deriving (Eq, Ord)
Expand Down Expand Up @@ -152,9 +151,6 @@ foreign import ccall unsafe "zmq.h zmq_connect"
foreign import ccall unsafe "zmq.h zmq_send"
c_zmq_send :: ZMQSocket -> ZMQMsgPtr -> CInt -> IO CInt

foreign import ccall unsafe "zmq.h zmq_flush"
c_zmq_flush :: ZMQSocket -> IO CInt

foreign import ccall safe "zmq.h zmq_recv"
c_zmq_recv :: ZMQSocket -> ZMQMsgPtr -> CInt -> IO CInt

Expand Down
2 changes: 1 addition & 1 deletion zeromq-haskell.cabal
@@ -1,5 +1,5 @@
name: zeromq-haskell
version: 0.2.1
version: 0.2.2
synopsis: bindings to zeromq
description: Bindings to zeromq (http://zeromq.org)
category: System, FFI
Expand Down

0 comments on commit 428ed0b

Please sign in to comment.