aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/join.py11
-rwxr-xr-xsrc/test.py18
2 files changed, 29 insertions, 0 deletions
diff --git a/src/join.py b/src/join.py
index a873bf4..a79d32c 100644
--- a/src/join.py
+++ b/src/join.py
@@ -223,3 +223,14 @@ def concurrently(*fs):
for t in ts:
t.join()
+
+
+def joinmethod(f):
+ '''
+ Make a fragment of signal an instance method rather than a static method
+
+ @param f:(self, *..., **...)→¿R? The static method
+ @return f:(self, *..., **...)→¿R? The method made into a instance method
+ '''
+ return lambda self, *args, **kwargs : f(self, *args, **kwargs)
+
diff --git a/src/test.py b/src/test.py
index 0279f2d..a0125df 100755
--- a/src/test.py
+++ b/src/test.py
@@ -153,3 +153,21 @@ unjoining(1)
unjoining(2)
print()
+
+class C:
+ def __init__(self, value):
+ self.value = value
+
+ @joinmethod
+ @fragment
+ def f(self, v):
+ print(' %i' % (self.value + v))
+
+f1 = C(1).f
+f2 = C(2).f
+
+print('Testing @joinmethod, expecting 11,22')
+f1(10)
+f2(20)
+print()
+