From: Jean Privat Date: Thu, 24 Sep 2015 17:21:26 +0000 (-0400) Subject: lib/core/stream: add start/finish for Stream X-Git-Tag: v0.7.8~3^2~1 X-Git-Url: http://nitlanguage.org lib/core/stream: add start/finish for Stream Signed-off-by: Jean Privat --- diff --git a/lib/core/stream.nit b/lib/core/stream.nit index b4a0e2b..ecfc77e 100644 --- a/lib/core/stream.nit +++ b/lib/core/stream.nit @@ -39,6 +39,26 @@ abstract class Stream # close the stream fun close is abstract + + # Pre-work hook. + # + # Used to inform `self` that operations will start. + # Specific streams can use this to prepare some resources. + # + # Is automatically invoked at the beginning of `with` structures. + # + # Do nothing by default. + fun start do end + + # Post-work hook. + # + # Used to inform `self` that the operations are over. + # Specific streams can use this to free some resources. + # + # Is automatically invoked at the end of `woth` structures. + # + # call `close` by default. + fun finish do close end # A `Stream` that can be read from