Copyright | (c) Anton Gushcha, 2016 |
---|---|
License | BSD3 |
Maintainer | ncrashed@gmail.com |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
- data AsyncState s = AsyncState {
- asyncAValues :: !AsyncValueMap
- asyncScheduled :: !SyncSheduled
- asyncSValues :: !SyncFinished
- asyncNextId :: !Int
- asyncNextState :: !s
- emptyAsyncState :: s -> AsyncState s
- newtype AsyncId = AsyncId {}
- type AsyncValueMap = HashMap AsyncId (Either (Async Dynamic) (Either SomeException Dynamic))
- registerAsyncValue :: Typeable a => Async a -> AsyncState s -> (AsyncId, AsyncState s)
- getFinishedAsyncValue :: AsyncId -> AsyncState s -> Maybe (Maybe (Either SomeException Dynamic))
- cancelAsyncValue :: AsyncId -> AsyncState s -> (Maybe (Async Dynamic), AsyncState s)
- purgeAsyncs :: AsyncState s -> AsyncState s
- newtype SyncId = SyncId {}
- type SyncSheduled = Seq (SyncId, IO Dynamic)
- type SyncFinished = HashMap SyncId (Either SomeException Dynamic)
- registerSyncValue :: Typeable a => IO a -> AsyncState s -> (SyncId, AsyncState s)
- getFinishedSyncValue :: SyncId -> AsyncState s -> Maybe (Either SomeException Dynamic)
- cancelSyncValue :: SyncId -> AsyncState s -> AsyncState s
- purgeSyncs :: AsyncState s -> AsyncState s
Documentation
data AsyncState s Source #
Internal state of asynchronious core module
s
- - state of next module, they are chained until bottom, that is usually an empty data type.
AsyncState | |
|
Generic (AsyncState s) Source # | |
NFData s => NFData (AsyncState s) Source # | |
Monad m => MonadState (AsyncState s) (AsyncT s m) | |
type Rep (AsyncState s) Source # | |
emptyAsyncState :: s -> AsyncState s Source #
Create inital async state
s
- - state of next module
Async helpers
Id of async value, it is used to poll info about the value
type AsyncValueMap = HashMap AsyncId (Either (Async Dynamic) (Either SomeException Dynamic)) Source #
Container for async values
registerAsyncValue :: Typeable a => Async a -> AsyncState s -> (AsyncId, AsyncState s) Source #
Put async value into internal state
getFinishedAsyncValue :: AsyncId -> AsyncState s -> Maybe (Maybe (Either SomeException Dynamic)) Source #
cancelAsyncValue :: AsyncId -> AsyncState s -> (Maybe (Async Dynamic), AsyncState s) Source #
Unregister given id and return stored async
purgeAsyncs :: AsyncState s -> AsyncState s Source #
Deletes calculated values
Sync helpers
Id of sync value, it is used to identify return value
type SyncFinished = HashMap SyncId (Either SomeException Dynamic) Source #
Container for finished sync values
registerSyncValue :: Typeable a => IO a -> AsyncState s -> (SyncId, AsyncState s) Source #
Put sync value into internal state
getFinishedSyncValue :: SyncId -> AsyncState s -> Maybe (Either SomeException Dynamic) Source #
Try to get value of given sync value
Note: first Maybe
layer is test for existense of given async value
cancelSyncValue :: SyncId -> AsyncState s -> AsyncState s Source #
Unregister given sheduled sync action
purgeSyncs :: AsyncState s -> AsyncState s Source #
Deletes calculated values