UittrekselThe event-based programming paradigm allows programs to react upon input in the form of events. In contrast to traditional programming, where the flow of the program is determined by the program structure, the flow of an event-based program is driven by events. These events are detected by the event loop and it is up to the programmer to define how to react upon these events, by registering observers, also called event handlers. After the event loop has detected an event, the registered handlers process it and the event loop subsequently handles the next event.
When combining two event loops into a larger system, for example an event loop for the user interface and one for network events, the developer is forced to manually coordinate these event loops. Libraries already exist to integrate event loops, but they let one event loop take control over the other, instead of running them separately.
As we show, by implementing a case study, manually coordinating different event loops leads to a lot of excessive code, written by the programmer. In addition, some event loops are prey to lifecycle state changes, which means they can be killed by the system when e.g. memory runs low. When such an event loop is killed, it cannot process any events or receive communication from the other event loops. The existing libraries allow communication between event loops, but do not take into account these lifecycle state changes. Therefore, we propose a coordination model, Elector, that allows two event loops to run separately while providing a bridge between them. This does not only allow communication between the event loops, but lifecycle changes are handled in such a way that they do not influence the other event loops. As a validation, we rewrite our case study using this coordination model, and compare it to the first version. An identical application using the Elector framework, is 28% lines of code shorter and spends 97% on application logic instead of 75% for the ad hoc case.
|Begeleider||Wolfgang De Meuter (Promotor), Viviane Jonckers (Jury), Tom Van Cutsem (Jury), Ann Nowe (Jury), Dries Harnie (Advisor) & Kevin Pinte (Advisor)|