GithubHelp home page GithubHelp logo

Comments (4)

rjeczalik avatar rjeczalik commented on June 5, 2024

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.

ppknap avatar ppknap commented on June 5, 2024

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.

rjeczalik avatar rjeczalik commented on June 5, 2024

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.

ppknap avatar ppknap commented on June 5, 2024

Let it be

from notify.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.