current.set(this);
w.handle(evs);
} catch(Throwable t) {
- error(w, t);
+ error(w, t, "handling event");
+ } finally {
+ current.remove();
+ }
+ }
+
+ protected void close(Watcher w) {
+ try {
+ current.set(this);
+ w.close();
+ } catch(Throwable t) {
+ error(w, t, "closing");
} finally {
current.remove();
}
worker.submit(task);
}
- protected void error(Watcher w, Throwable t) {
- hlog.log(Level.WARNING, w + ": uncaught error when handling event", t);
+ protected void error(Watcher w, Throwable t, String thing) {
+ hlog.log(Level.WARNING, w + ": uncaught error when " + thing, t);
remove(w);
}
double timeout = w.timeout();
boolean hastime = timeout < Double.POSITIVE_INFINITY;
if(evs < 0) {
- submit(w::close);
+ submit(() -> close(w));
return;
}
w.added(Driver.this);
throw(new RuntimeException(w + ": inconsistent internal state"));
if(wc == null)
throw(new IllegalStateException(w + ": not registered"));
- submit(w::close);
+ submit(() -> close(w));
poll.wakeup();
}