First time dmon user, and it immediately blew up! (When trying to set a watch to a directory that didn't exist. win10.)
So here's a bunch of fixes to make it work more reliably.
Copied from the commit:
_dmon.modify_watches is gone. Its use introduced more hazard than gain.
Fix possible race conditions when watch creation failed
Actually handle errors properly instead of corrupting internal state
Don't keep the global mutex held while lazing around in Sleep()
Since watches are always deleted in unwatch, there's no use trying to keep a pool of allocated watches around for re-use
I've been thinking to remove the weird "freelist" construct too, if you're ok with that.
Because we can just loop over the (compile-time-bounded) array of active watches and pick the first index that's NULL. Since adding and removing watches is nothing done on a per-frame basis a couple loop iterations don't matter. I'd prefer the gained simplicity.
_dmon.quit should be at least volatile (done now), but an atomic would be even better. Comments?
Lasty, do you mind if i get rid of the #include for the windows backend? Because I like backwards compatbility with older compilers and this is the single most annoying header to break MSVC <= 2012-ish compatibility.
I'll add some extra commits to the PR when i get the go-ahead from you.
First time dmon user, and it immediately blew up! (When trying to set a watch to a directory that didn't exist. win10.) So here's a bunch of fixes to make it work more reliably.
Copied from the commit:
I've been thinking to remove the weird "freelist" construct too, if you're ok with that.
Because we can just loop over the (compile-time-bounded) array of active watches and pick the first index that's NULL. Since adding and removing watches is nothing done on a per-frame basis a couple loop iterations don't matter. I'd prefer the gained simplicity.
_dmon.quit should be at least volatile (done now), but an atomic would be even better. Comments?
Lasty, do you mind if i get rid of the #include for the windows backend? Because I like backwards compatbility with older compilers and this is the single most annoying header to break MSVC <= 2012-ish compatibility.
I'll add some extra commits to the PR when i get the go-ahead from you.