From 930fb882d4df7ebb87c02c13e03e97eb35f2904e Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Thu, 24 Sep 2015 13:21:26 -0400 Subject: [PATCH] lib/core/stream: add start/finish for Stream Signed-off-by: Jean Privat --- lib/core/stream.nit | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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 -- 1.7.9.5