gore-and-ash-async-0.1.0.0: Core module for Gore&Ash engine that embeds async IO actions into game loop.

Copyright(c) Anton Gushcha, 2016
LicenseBSD3
Maintainerncrashed@gmail.com
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Game.GoreAndAsh.Async.State

Contents

Description

 

Synopsis

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.

emptyAsyncState :: s -> AsyncState s Source

Create inital async state

s
- state of next module

Async helpers

newtype AsyncId Source

Id of async value, it is used to poll info about the value

Constructors

AsyncId 

Fields

unAsyncId :: Int
 

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

Try to get value of given async value

Note: first Maybe layer is test for existense of given async value

Note: second Maybe layer is test is the value is finished

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

newtype SyncId Source

Id of sync value, it is used to identify return value

Constructors

SyncId 

Fields

unSyncId :: Int
 

type SyncSheduled = Seq (SyncId, IO Dynamic) Source

Container for scheduled sync values

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