Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure for each watchee? #191

Closed
sjoshid opened this issue Apr 5, 2019 · 7 comments
Closed

Configure for each watchee? #191

sjoshid opened this issue Apr 5, 2019 · 7 comments

Comments

@sjoshid
Copy link
Contributor

sjoshid commented Apr 5, 2019

@passcod
Im integrating the new OnGoingWrite config (issue #146) in xi_editor. If Im not mistaken you can have many watchees for a single watcher. If that is the case then the behavior of OnGoingWrite event config would be incorrect.

let mut watcher: RecommendedWatcher = try!(Watcher::new(tx, Duration::from_secs(2)));
watcher.config(Config(Some(Duration::from_millis(10000))));
try!(watcher.watch("/home/test/notify1", RecursiveMode::Recursive));
try!(watcher.watch("/home/test/notify2", RecursiveMode::Recursive));

We do something similar in xi-editor.
What we have right now needs to be tweaked a little bit.
If you agree I can get this fixed.

@passcod
Copy link
Member

passcod commented Apr 5, 2019

Can you explain how it would be incorrect?

@sjoshid
Copy link
Contributor Author

sjoshid commented Apr 6, 2019

Lets suppose there are two files A and B where ongoing write is happening and ongoing duration is 10. A sends an event at i and B sends at i + 1. Since there is only one ongoing_write_event in timer the event at i + 1 will not be scheduled because there is already an event from A scheduled to be fired at i + 10.
In short: until event from A is fired no other event can be scheduled. This is incorrect.
What should happen is both events, from A and B must be scheduled to be fired at i + 10 and i + 11 respectively.

@passcod
Copy link
Member

passcod commented Apr 6, 2019 via email

@sjoshid
Copy link
Contributor Author

sjoshid commented Apr 7, 2019

Yes. I have started work on a fix. But if I cannot get this done by mid-april release (work is going to be crazy this week)...I would like to have the Configure feature reverted. No point in having half-baked feature in a new release.

On a different note... I get a bunch of build errors on Windows on main branch. Is it a WIP?

@passcod
Copy link
Member

passcod commented Apr 12, 2019

Main branch is currently WIP, yes, although it should build on Windows (so says Travis CI, anyway). I'm pretty sure I have fixed the issue you bring up, can you review the latest?

passcod added a commit that referenced this issue Apr 12, 2019
The original implementation used a single Option in a Mutex to hold the
current path undergoing ongoing writes. The issue brought up by Sujit
Joshi in #191 was that this fails to perform correctly when more than
one path is undergoing ongoing writes.

The solution is to instead use a map to hold path -> instant pairs.
Because the map has to be shared between threads, and besides needs to
be held from two structs at once, a CHashMap is used. An ad-hoc
construction with stdlib data structures and sync primitives could have
been set up, but the CHashMap saves that boilerplate and offers elegant
usage patterns that make the code clearer and more understandable.

Additionally, another issue was identified in that the ongoing event
state was not cleared when the feature is disabled.

Finally, the terminology was changed from ongoing duration -> delay,
and various identifiers internally were made more concise.
@passcod passcod closed this as completed Apr 13, 2019
@sjoshid
Copy link
Contributor Author

sjoshid commented Apr 13, 2019

Thanks for fixing this. Sorry I couldn't get it to sooner. I got a chance to review this and I must say your implementation is far better, clean and easy to read. The WHAT part is similar to what I was doing but the HOW part is a lot different thanks to CHashMap. Im new to Rust so thanks for introducing me to this data structure!!

Few comments/questions:

  • Are we not allowing each path to have different delay?
  • There is a tiny bug in handle_ongoing_write. We need to update the value after firing the event. So adding *fire_at = Instant::now() + delay; after firing the event is necessary.

Other than that .. I didnt see any issues.

@passcod
Copy link
Member

passcod commented Apr 13, 2019 via email

sjoshid referenced this issue in sjoshid/xi-editor Nov 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants