I have class, lets call it "Engine", which contains something like event loop, logic of which can be explained by the following pseudo code:
for(;;) {
int interruptId;
waitForInterrupt(); // blocking wait
switch(interruptId) {
case REQUEST_DATA:
doSomeStuff();
...
}
}
the event loop is intended for interrupts processing (which come from driver of a hardware device). Engine will be used by client. Client should be able to start/stop engine. But starting the engine shouldn't suspend the client.
My intention: when Engine is started it starts a new thread where event loop for(;;) is executed.
Question is it a solution to go, could you propose existing design patterns applicable in this case, any advices on implementations and possible bottlenecks that I should take into account.
Aucun commentaire:
Enregistrer un commentaire