aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/join.py6
-rwxr-xr-xsrc/test.py4
2 files changed, 6 insertions, 4 deletions
diff --git a/src/join.py b/src/join.py
index f4cc967..76b7445 100644
--- a/src/join.py
+++ b/src/join.py
@@ -151,7 +151,7 @@ def ordered_join(*f_groups):
If there are matched fragments groups that have already returned, the one
that appears first the case set is selected.
- @param f_groups:*itr<fragment> The fragments groups
+ @param f_groups:*(itr<fragment>|fragment) The fragment groups
@return :(int, (args:tuple<...>, kwargs:dict<str, ...>, rc:¿R?)|list<←>)
The index (zero-based) of the selected case and the positional arguments, and
arguments with which the fragments were invoked and the value returned (extension
@@ -160,6 +160,7 @@ def ordered_join(*f_groups):
condition = threading.Condition()
rc, done = None, False
index = 0
+ f_groups = [((group,) if isinstance(group, fragment) else group) for group in f_groups]
for f_group in f_groups:
def join_(fs, index):
nonlocal rc, done, condition
@@ -196,12 +197,13 @@ def unordered_join(*f_groups):
If there are matched fragments groups that have already returned, one is
selected at random, uniformally.
- @param f_groups:*itr<fragment> The fragments groups
+ @param f_groups:*(itr<fragment>|fragment) The fragment groups
@return :(int, (args:tuple<...>, kwargs:dict<str, ...>, rc:¿R?)|list<←>)
The index (zero-based) of the selected case and the positional arguments, and
arguments with which the fragments were invoked and the value returned (extension
to join-calculus) by those invocations (as a list of not exactly one fragement)
'''
+ f_groups = [((group,) if isinstance(group, fragment) else group) for group in f_groups]
ready = [i for i, fs in enumerate(f_groups) if all([len(f.queue) for f in fs])]
if len(ready):
i = ready[random.randrange(len(ready))]
diff --git a/src/test.py b/src/test.py
index 8f381bf..6b4c8af 100755
--- a/src/test.py
+++ b/src/test.py
@@ -36,7 +36,7 @@ def f3():
def unordered_f123():
- (case, (jargs, jkwargs, jrc)) = unordered_join((f1,), (f2,), (f3,))
+ (case, (jargs, jkwargs, jrc)) = unordered_join((f1,), f2, (f3,))
return case
def unordered():
@@ -52,7 +52,7 @@ print()
def ordered_f123():
- (case, (jargs, jkwargs, jrc)) = ordered_join((f1,), (f2,), (f3,))
+ (case, (jargs, jkwargs, jrc)) = ordered_join((f1,), f2, (f3,))
return case
def ordered():