lib/streams: Added interface Pollable to Stream hierarchy
authorLucas Bajolet <r4pass@hotmail.com>
Fri, 2 May 2014 18:57:02 +0000 (14:57 -0400)
committerLucas Bajolet <r4pass@hotmail.com>
Fri, 2 May 2014 19:05:35 +0000 (15:05 -0400)
Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

lib/standard/file.nit
lib/standard/stream.nit

index 5ff333c..ebe06c2 100644 (file)
@@ -178,15 +178,15 @@ end
 
 class Stdin
        super IFStream
+       super PollableIStream
+
        private init do
                _file = new NativeFile.native_stdin
                path = "/dev/stdin"
                prepare_buffer(1)
        end
 
-       # Is these something to read? (non blocking)
-       # FIXME: should be generalized
-       fun poll_in: Bool is extern "file_stdin_poll_in"
+       redef fun poll_in: Bool is extern "file_stdin_poll_in"
 end
 
 class Stdout
index 932919b..29501ee 100644 (file)
@@ -88,6 +88,15 @@ interface IStream
        fun eof: Bool is abstract
 end
 
+# IStream capable of declaring if readable without blocking
+interface PollableIStream
+       super IStream
+
+       # Is there something to read? (without blocking)
+       fun poll_in: Bool is abstract
+
+end
+
 # Abstract output stream
 interface OStream
        super IOS