diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2014-02-19 05:16:09 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2014-02-19 05:16:09 +0400 |
commit | 9dda7109e1877821612488602cbea3014a3e8566 (patch) | |
tree | 42e5973765a3653b91ef46ae43689841b7a46aa5 | |
parent | 41ca2fc6ece3e24542703035c4249f409eca3906 (diff) |
Add function isActive
-rw-r--r-- | src/Network/KRPC.hs | 1 | ||||
-rw-r--r-- | src/Network/KRPC/Manager.hs | 7 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/Network/KRPC.hs b/src/Network/KRPC.hs index f7b8378a..b15927cf 100644 --- a/src/Network/KRPC.hs +++ b/src/Network/KRPC.hs | |||
@@ -74,6 +74,7 @@ module Network.KRPC | |||
74 | , newManager | 74 | , newManager |
75 | , closeManager | 75 | , closeManager |
76 | , withManager | 76 | , withManager |
77 | , isActive | ||
77 | , listen | 78 | , listen |
78 | 79 | ||
79 | -- * Re-exports | 80 | -- * Re-exports |
diff --git a/src/Network/KRPC/Manager.hs b/src/Network/KRPC/Manager.hs index e0ea9618..4436a9ba 100644 --- a/src/Network/KRPC/Manager.hs +++ b/src/Network/KRPC/Manager.hs | |||
@@ -24,6 +24,7 @@ module Network.KRPC.Manager | |||
24 | , newManager | 24 | , newManager |
25 | , closeManager | 25 | , closeManager |
26 | , withManager | 26 | , withManager |
27 | , isActive | ||
27 | , listen | 28 | , listen |
28 | 29 | ||
29 | -- * Queries | 30 | -- * Queries |
@@ -192,6 +193,12 @@ closeManager Manager {..} = do | |||
192 | -- TODO unblock calls | 193 | -- TODO unblock calls |
193 | close sock | 194 | close sock |
194 | 195 | ||
196 | -- | Check if the manager is still active. Manager becomes active | ||
197 | -- until 'closeManager' called. | ||
198 | isActive :: Manager m -> IO Bool | ||
199 | isActive Manager {..} = liftIO $ isBound sock | ||
200 | {-# INLINE isActive #-} | ||
201 | |||
195 | -- | Normally you should use Control.Monad.Trans.Resource.allocate | 202 | -- | Normally you should use Control.Monad.Trans.Resource.allocate |
196 | -- function. | 203 | -- function. |
197 | withManager :: Options -> SockAddr -> [Handler h] | 204 | withManager :: Options -> SockAddr -> [Handler h] |