Configure channel blocking as part of adding to the event-loop.
[jagi.git] / src / jagi / event / Driver.java
index 6ee920f..8fe83a7 100644 (file)
@@ -184,6 +184,11 @@ public class Driver {
        void add(Watcher w, SelectableChannel ch) {
            if(watching.containsKey(w) || paused.containsKey(w) || timeheap.contains(w))
                throw(new IllegalStateException(w + ": already registered"));
+           try {
+               ch.configureBlocking(false);
+           } catch(IOException e) {
+               throw(new RuntimeException(ch + ": could not make non-blocking", e));
+           }
            int evs = w.events();
            double timeout = w.timeout();
            boolean hastime = timeout < Double.POSITIVE_INFINITY;