From 2c215c8f26f135e304fb653fc0b3fd0eab856e7f Mon Sep 17 00:00:00 2001 From: Sam T Date: Tue, 27 Aug 2013 01:39:37 +0400 Subject: - Remove async API. --- src/Remote/KRPC.hs | 53 ++++++----------------------------------------------- 1 file changed, 6 insertions(+), 47 deletions(-) (limited to 'src') diff --git a/src/Remote/KRPC.hs b/src/Remote/KRPC.hs index 88882da2..ab989782 100644 --- a/src/Remote/KRPC.hs +++ b/src/Remote/KRPC.hs @@ -80,6 +80,8 @@ -- Here we implement method signature from that shared lib and run -- server with runServer by passing method table in. -- +-- For async API use /async/ package, old API have been removed. +-- -- For more examples see @exsamples@ or @tests@ directories. -- -- For protocol details see 'Remote.KRPC.Protocol' module. @@ -100,10 +102,12 @@ module Remote.KRPC -- * Client , RemoteAddr , RPCException(..) - , call, Async, async, await + , call -- * Server - , MethodHandler, (==>), server + , MethodHandler + , (==>) + , server -- * Internal , call_ @@ -301,51 +305,6 @@ call_ sock addr m arg = liftIO $ do getResult sock m --- | Asynchonous result typically get from 'async' call. Used to defer --- return values transfer. -newtype Async result = Async { waitResult :: IO result } - - --- | Query procedure call but not wait for its results. This function --- returns 'Async' value which is handle to procedure result. Actual --- result might be obtained with 'await'. Unable to throw --- 'RPCException', this might happen in 'await' if at all. --- --- Note that sending multiple queries at the same time to the one --- remote is not recommended. For exsample in the following scenario: --- --- > aa <- async theRemote .... --- > ab <- async theRemote .... --- > a <- await ab --- > b <- await ab --- --- it's likely that the /a/ and /b/ values will be mixed up. So in --- order to get correct results you need to make 'await' before the --- next 'async'. --- -async :: MonadIO host - => (BEncodable param, BEncodable result) - => RemoteAddr -- ^ Address of callee. - -> Method param result -- ^ Procedure to call. - -> param -- ^ Arguments passed by callee to procedure. - -> host (Async result) -- ^ Handle to result. -async addr m arg = do - liftIO $ withRemote $ \sock -> - queryCall sock addr m arg - return $ Async $ withRemote $ \sock -> - getResult sock m - --- | Will wait until the callee finished processing of procedure call --- and return its results. Throws 'RPCException' on any error --- occurred. -await :: MonadIO host - => Async result -- ^ Obtained from the corresponding 'async'. - -> host result -- ^ Result values of the procedure call quered - -- with 'async'. -await = liftIO . waitResult -{-# INLINE await #-} - - type HandlerBody remote = KQuery -> remote (Either KError KResponse) -- | Procedure signature and implementation binded up. -- cgit v1.2.3