
I use my nonblocking library: eg for IRC bot: let myCallbacks = defaultCallbacks { done_connected = binded, done_reading = response_get tm ref stdgen gsref, done_writing = response_written, done_closed = \pl s -> do putStrLn "peer closed, reconnecting" s <- socket myCallbacks connect pl s "83.140.172.212:6667" return 1, handle_error = \pl s buf len-> do str <- peekCStringLen (buf,fromIntegral len) putStrLn $ "error "++str++", reconnecting" s <- socket myCallbacks connect pl s "83.140.172.212:6667" return 1, tick = binded_tick tm } s <- socket myCallbacks pl <- epoll 1000 connect pl s "83.140.172.212:6667" run_loop pl (-1) On 3/19/20 3:40 PM, Michael Hull wrote:
Hi Niklas and Patrick,
Thankyou both for the comments -- this is what I am looking for.
I have a follow-on question, if I have code like
getPages :: IO() getPages = do (page1, page2, page3) <- runConcurrently $ (,,) <$> Concurrently (getURL "url1") <*> Concurrently (getURL "url2") <*> Concurrently (getURL "url3")
main :: IO() main = do f <- async getPages cancel f
Am I guaranteed the the getURL() calls will definitely have either finished, or cancel? (I looked through the source (https://hackage.haskell.org/package/async-2.2.2/docs/src/Control.Concurrent....), and I think so, because runConcurrently is implemented in terms of race, which is implemented using withAsync, but I'm not confident with interpreting Haskell!)
Many thanks,
Mike
On Wed, 18 Mar 2020 at 03:15, Niklas Hambüchen
mailto:mail@nh2.me> wrote: I've you're new to async, also check out my recent rework of the docs that talk about this topic specifically:
https://github.com/simonmar/async/pull/105/files
(To be available in the next release of async.)
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.