Commit a691b2d8 authored by kazu-yamamoto's avatar kazu-yamamoto Committed by tibbe

minor refactoring.

parent 65309d8c
......@@ -115,12 +115,13 @@ poll :: EPoll -- ^ state
-> IO Int
poll ep mtimeout f = do
let events = epollEvents ep
fd = epollFd ep
-- Will return zero if the system call was interupted, in which case
-- we just return (and try again later.)
n <- A.unsafeLoad events $ \es cap -> case mtimeout of
Just timeout -> epollWait (epollFd ep) es cap $ fromTimeout timeout
Nothing -> epollWaitNonBlock (epollFd ep) es cap
Just timeout -> epollWait fd es cap $ fromTimeout timeout
Nothing -> epollWaitNonBlock fd es cap
when (n > 0) $ do
A.forM_ events $ \e -> f (eventFd e) (toEvent (eventTypes e))
......
......@@ -116,10 +116,11 @@ poll :: KQueue
-> IO Int
poll kq mtimeout f = do
let events = kqueueEvents kq
fd = kqueueFd kq
n <- A.unsafeLoad events $ \es cap -> case mtimeout of
Just timeout -> kqueueWait (kqueueFd kq) es cap $ fromTimeout timeout
Nothing -> kqueueWaitNonBlock (kqueueFd kq) es cap
Just timeout -> kqueueWait fd es cap $ fromTimeout timeout
Nothing -> kqueueWaitNonBlock fd es cap
when (n > 0) $ do
A.forM_ events $ \e -> f (fromIntegral (ident e)) (toEvent (filter e))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment