From 508290c998106df292484a8f9b92c72794020c9e Mon Sep 17 00:00:00 2001 From: Sven Augustin Date: Sat, 5 Jun 2021 15:35:26 +0200 Subject: [PATCH] added CachedSource mixin --- kabuki/sources/cachedsource.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 kabuki/sources/cachedsource.py diff --git a/kabuki/sources/cachedsource.py b/kabuki/sources/cachedsource.py new file mode 100644 index 0000000..6621374 --- /dev/null +++ b/kabuki/sources/cachedsource.py @@ -0,0 +1,18 @@ +from ..cacher import Cache + + +class CachedSource: + + def __init__(self, size=1): + self.cache = cache = Cache(size=size) + self.cb = self.add_callback(cache.callback_append) + + def disconnect(self): + self.remove_callback(self._cb) + + + +#TODO: check if source is connected before adding callback + + +