Safe Haskell | Safe |
---|
- data SchedulerIO s a where
- SchedulerIO :: Scheduler s => (s -> IO a) -> SchedulerIO s a
- getCurrentScheduler :: Scheduler s => SchedulerIO s s
- class Scheduler s where
- schedule :: s -> SchedulerIO s () -> IO Disposable
- schedulerMain :: s -> IO ()
- newtype BackgroundScheduler = BackgroundScheduler (TQueue (ScheduledAction BackgroundScheduler))
- data ScheduledAction s
- newScheduledAction :: Scheduler s => SchedulerIO s () -> IO (ScheduledAction s, Disposable)
- executeScheduledAction :: Scheduler s => s -> ScheduledAction s -> IO ()
Documentation
data SchedulerIO s a whereSource
An IO
computation that must be performed in a scheduler of type s
.
SchedulerIO :: Scheduler s => (s -> IO a) -> SchedulerIO s a |
Scheduler s => Monad (SchedulerIO s) | |
Functor (SchedulerIO s) | |
Scheduler s => Applicative (SchedulerIO s) | |
Scheduler s => MonadIO (SchedulerIO s) | |
Show v => Show (SchedulerIO BackgroundScheduler v) | |
Show v => Show (SchedulerIO MainScheduler v) | Unsafely executes a |
getCurrentScheduler :: Scheduler s => SchedulerIO s sSource
Returns the scheduler that the calling code is executing on.
Represents a queue of IO
actions which can be executed in FIFO order.
schedule :: s -> SchedulerIO s () -> IO DisposableSource
Schedules an action on the scheduler. Returns a disposable which can be used to cancel it.
schedulerMain :: s -> IO ()Source
Executes all current and future actions enqueued on the given scheduler.
newtype BackgroundScheduler Source
A scheduler which runs enqueued actions in a dedicated background thread.
data ScheduledAction s Source
Represents an action on a scheduler, along with a flag indicating whether it should be canceled.
newScheduledAction :: Scheduler s => SchedulerIO s () -> IO (ScheduledAction s, Disposable)Source
Creates a new scheduled action, and returns a disposable which can be used to cancel it.
executeScheduledAction :: Scheduler s => s -> ScheduledAction s -> IO ()Source
Executes the given action, then re-enters schedulerMain
.