eventloop- A different take on an IO system. Based on Amanda's IO loop, this eventloop takes a function that maps input events to output events. It can easily be extended by modules that represent IO devices or join multiple modules together.

Safe HaskellNone




startEventloopSystem :: EventloopSetupConfiguration progstateT -> IO () Source

Starts the entire system. First the setup phase is handled to setup the different concurrent resources. This is followed by the initialization phase where all modules are initialised. Than, the different worker threads are spawned and finally the system thread will go to work as the eventloop thread.

Shutting down is handled centrally through the system thread (main thread). If any of the threads(including the system thread) receive an exception, only the first exception is thrown to the system thread which will try to shutdown immediately. This exception is logged by the system thread. All other exceptions are logged by their respective threads. The system thread will than shutdown the worker threads. This is done by throwing exceptions to all workerthreads except sender threads. These are sent a Stop event. If they take longer than 1 second, to finish up, they will also be thrown an exception.

threadActionsBasedOnModule :: EventloopSystemConfiguration progstateT -> (EventloopSystemConfiguration progstateT -> (EventloopModuleConfiguration, resource) -> IO ()) -> (EventloopModuleConfiguration -> Maybe resource) -> [EventloopModuleConfiguration] -> [IO ()] Source

Utility function in order to create the different thread actions in the system. Assumed is that the action requires the system configuration, the module configuration and some resource that may be available in the module configuration.