Comments (4)
The runtime will work exactly like this where possible, the only issue is the interface - the runtime can't and won't call Unwatch(path, events)
as it's unable to determine whether watcher implementation supports "editing" the watcher, thus this decision is taken per each watcher implementation via Rewatch
.
So the bottom line is - if the Watcher can support this it's perfect, however it's not the runtime which can make the decision. In this particular example on 5th line the runtime would call Rewatch(p1, Create|Delete, Create)
and it's up to Watcher implementation figuring out that it should call partialUnwatch(p1, Delete)
internally, as this logic is not multi-platform.
Example
Capable watcher would call partialUnwatch(p1, Delete)
on 5th line, and dumb watcher (sorry FSEvents) would call Unwatch(p1); Watch(p1, Create)
for the same line and in order to do this, it requires full sets of events (it's simplified a bit for the sake of example, in order to unwatch it needs old set of events, and the new one is needed for the final, "optimised" watch).
The Rewatch
just happen to support both scenarios ;)
from notify.
For inotify the implementation would look like this:
Rewatch(path string, maskold, masknew Event) error {
return Watch(path, masknew)
}
The only problem I have is the second argument. Why do we need it for? If all the old masks are kept by internal implementation itself, the oldmask variable is redundant and useless. Thus, if the we don't need the 2nd arg, cannot Watch function handle this by replacing old mask with the new one? This is only a suggestion and if you realy need this function then let it be.
from notify.
Why do we need it for?
Only to have proper interface. The logic behind runtime is pretty simple:
- it calls
Watch
only when it wants to create new watch-point - it calls
Unwatch
only when it wants to delete a watch-point - it calls
Rewatch
when it wants to change properties of a watch-point (currently expand / reduce event set)
You can't merge those methods into one, even if you can implement all three of them with the same function.
As Rewatch
changes state of a watch-point, it passes both old and a new state. Eventually, if we implement everything altogether with native AIXD and it turns out that the interface can be simplified, it would get simplified.
from notify.
Let it be
from notify.
Related Issues (20)
- Panic in windows on loopevent HOT 3
- build error from mac osx 10.15 fatal error: 'CoreServices/CoreServices.h' file not found HOT 8
- Zero action causing "panic: notify: cannot decode internal mask" HOT 3
- NonrecursiveTree does not watch recreated folders
- Recursive watcher for windows shared drive does not report events in subdirectories HOT 1
- FILE_TRUNC does not exist on Solaris
- Can't cross compile for darwin/arm64 from darwin/amd64 HOT 1
- Still "under active development"? HOT 2
- SIGSEGV when built with 1.17 on macOS HOT 1
- Only listen for folder additions or deletions, but not file additions or deletions ?
- C.FSEventStreamScheduleWithRunLoop(ref, runloop, C.kCFRunLoopDefaultMode) MacOS 13 future remove HOT 4
- This library does not build on macOS ventura (13.0.1) HOT 1
- v0.9.3(4?) release naming HOT 2
- FSEvents are sometimes not notified due to strip() logic following rename
- fatal error: checkptr: converted pointer straddles multiple allocations HOT 2
- inotify event path may be incorrect if wd is not yet updated to its new path
- undefined: stream - Issue with Mac OS M2 HOT 6
- FSEventStreamCreate is not available at ios HOT 5
- "The parameter is incorrect." error when watching files on Windows HOT 1
- Recursive dir watching on Linux seems unreliable HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from notify.