Closed greenfork closed 4 years ago
Good question! I haven't chosen best way to do it yet, but currently there is a solution without any patches: just create VideoSystem.running
property:
type VideoSystem
running: bool
method init(self: ref VideoSystem) =
self.running = True
# ...
method process(self: ref VideoSystem, message: ref WindowQuitMessage) =
self.running = False
proc run*(self: ref VideoSystem) =
loop(frequency = 30) do:
while true:
let message = tryRecv()
if message.isNil: break
self.process(message)
self.update(dt)
if not self.running:
break
That works, thank you!
As I understand, I need to return from
run
proc in order to finish this thread's loop.I can patch
loop
to have a bool variable which controls thewhile
statement. Or I can patchprocess
to return something and use it to return fromrun
. What is the recommended design here? Both my suggestions require modifying the core framework systems.