@Override public void cancel() { valid.set(false); watcher.cancelled(this); }
@Override public void close() { super.close(); synchronized (this) { // synchronize to ensure no new for (Key key : snapshots.keySet()) { key.cancel(); } pollingService.shutdown(); fileSystemState.unregister(this); } }
@Override public WatchKey register(WatchService watcher, WatchEvent.Kind<?>... events) throws IOException { checkNotNull(watcher); checkNotNull(events); if (!(watcher instanceof AbstractWatchService)) { throw new IllegalArgumentException( "watcher (" + watcher + ") is not associated with this file system"); } AbstractWatchService service = (AbstractWatchService) watcher; return service.register(this, Arrays.asList(events)); }
@Override public boolean isValid() { return watcher.isOpen() && valid.get(); }
/** * Sets the state to SIGNALLED and enqueues this key with the watcher if it was previously in * the READY state. */ public void signal() { if (state.getAndSet(State.SIGNALLED) == State.READY) { watcher.enqueue(this); } }
/** * Registers the given watchable with this service, returning a new watch key for it. This * implementation just checks that the service is open and creates a key; subclasses may override * it to do other things as well. */ public Key register(Watchable watchable, Iterable<? extends WatchEvent.Kind<?>> eventTypes) throws IOException { checkOpen(); return new Key(this, watchable, eventTypes); }
@Override public Key register(Watchable watchable, Iterable<? extends WatchEvent.Kind<?>> eventTypes) throws IOException { JimfsPath path = checkWatchable(watchable); Key key = super.register(path, eventTypes); Snapshot snapshot = takeSnapshot(path); synchronized (this) { snapshots.put(key, snapshot); if (pollingFuture == null) { startPolling(); } } return key; }
/** * Enqueues the given key if the watch service is open; does nothing otherwise. */ final void enqueue(Key key) { if (isOpen()) { queue.add(key); } }
/** * Sets the state to SIGNALLED and enqueues this key with the watcher if it was previously in * the READY state. */ public void signal() { if (state.getAndSet(State.SIGNALLED) == State.READY) { watcher.enqueue(this); } }
/** * Registers the given watchable with this service, returning a new watch key for it. This * implementation just checks that the service is open and creates a key; subclasses may override * it to do other things as well. */ public Key register(Watchable watchable, Iterable<? extends WatchEvent.Kind<?>> eventTypes) throws IOException { checkOpen(); return new Key(this, watchable, eventTypes); }
@Override public WatchKey register(WatchService watcher, WatchEvent.Kind<?>... events) throws IOException { checkNotNull(watcher); checkNotNull(events); if (!(watcher instanceof AbstractWatchService)) { throw new IllegalArgumentException( "watcher (" + watcher + ") is not associated with this file system"); } AbstractWatchService service = (AbstractWatchService) watcher; return service.register(this, Arrays.asList(events)); }
@Override public boolean isValid() { return watcher.isOpen() && valid.get(); }
@Override public void close() { super.close(); synchronized (this) { // synchronize to ensure no new for (Key key : snapshots.keySet()) { key.cancel(); } pollingService.shutdown(); fileSystemState.unregister(this); } }
@Override public void cancel() { valid.set(false); watcher.cancelled(this); }
@Override public Key register(Watchable watchable, Iterable<? extends WatchEvent.Kind<?>> eventTypes) throws IOException { JimfsPath path = checkWatchable(watchable); Key key = super.register(path, eventTypes); Snapshot snapshot = takeSnapshot(path); synchronized (this) { snapshots.put(key, snapshot); if (pollingFuture == null) { startPolling(); } } return key; }
/** * Enqueues the given key if the watch service is open; does nothing otherwise. */ final void enqueue(Key key) { if (isOpen()) { queue.add(key); } }