I don't have much experience on blocking programs yet...
Based on https://github.com/paul-nameless/nim-fswatch
import libfswatch
import libfswatch/fswatch
proc callback(event: fsw_cevent, event_num: cuint) =
echo event.path
var mon = newMonitor()
mon.addPath("/tmp/test/")
mon.setCallback(callback)
mon.start()
and mon.start() is blocking.
Meanwhile I want to launch a window, which also wants to block my program using a while true loop.
Now the problem is mon.start() has blocked the problem, how can I respond to window as well?
Tried to put window in a thread. Since I was using sdl2, sdl2 threw an error that it has to be running in a main thread. Then I saw people using spawn for tasks, but as I tried, the compiler told me that mon.setCallback is not GC safe. Got no other solutions to try...