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

addWatch: don't cancel other watches #7

Merged
merged 2 commits into from Apr 27, 2014
Merged

addWatch: don't cancel other watches #7

merged 2 commits into from Apr 27, 2014

Conversation

UnkindPartition
Copy link
Contributor

Previously, addWatch would override any actions already registered with the
same watch descriptor (i.e. related to the same path). This commit changes the
behaviour so that the previously registered actions are kept.

Here's the test I used for this:

import Control.Concurrent
import Control.Exception
import Control.Applicative
import System.INotify

main = do
  ino <- initINotify
  let foo = "foo"
  writeFile foo "blah"

  _ <- addWatch ino [Open] foo $ \e -> putStrLn "opened"
  evaluate =<< length <$> readFile foo
  threadDelay (10^6)

  _ <- addWatch ino [Access] foo $ \e -> putStrLn "accessed"
  evaluate =<< length <$> readFile foo
  threadDelay (10^6)

It's in a different style than the project's tests (it registers the actions rather than just gathering the events), so I didn't include it, but feel free to adapt it for the test suite.

Previously, addWatch would override any actions already registered with the
same watch descriptor (i.e. related to the same path). This commit changes the
behaviour so that the previously registered actions are kept.
Ensure that if one handler for an event is killed by an exception, others
still get a chance to run.
@UnkindPartition
Copy link
Contributor Author

Good point, I didn't think of that. See the new commit.

@UnkindPartition
Copy link
Contributor Author

(reminder)

kolmodin added a commit that referenced this pull request Apr 27, 2014
addWatch: don't cancel other watches
@kolmodin kolmodin merged commit 9bc770b into kolmodin:master Apr 27, 2014
@kolmodin
Copy link
Owner

Released 0.3.7 with your changes.

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

Successfully merging this pull request may close these issues.

None yet

2 participants