diff options
Diffstat (limited to 'info/join-python.texinfo')
| -rw-r--r-- | info/join-python.texinfo | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/info/join-python.texinfo b/info/join-python.texinfo index e6f7b39..df311eb 100644 --- a/info/join-python.texinfo +++ b/info/join-python.texinfo @@ -54,6 +54,7 @@ Texts. A copy of the license is included in the section entitled * Signals:: The signal construct. * Fragments:: The fragment join construct. * Join-switches:: Advanced joining techniques. +* Fork–merge:: Running multiple functions concurrently synchronously * GNU Free Documentation License:: Copying and sharing this manual. @end menu @@ -269,6 +270,44 @@ that fragment group. +@node Fork–merge +@chapter Fork–merge + +As an extension to join-calculus Join Python offers +a blocking function that runs multiple functions +in parallel. @code{concurrently} takes any number +of functions and executes them in parallel and waits +for all of them to return. Functions that are +signals (@code{@@signal} or @code{@@puresignal}) +will have there return value returned by +@code{concurrently}. + +@cartouche +@example +>>> from join import * +>>> +>>> @@signal +>>> def sig(value = 4): +>>> print('In parallel') +>>> return value ** 2 +>>> +>>> def fun(value): +>>> print('In parallel') +>>> return value ** 3 +>>> +>>> print(concurrently(signal(lambda : sig(2).join()), lambda : fun(3))) +In parallel +In parallel +[4, None] # it is actually undefined where we get `None` here +>>> print(concurrently(sig, signal(lambda : fun(3)))) +In parallel +In parallel +[16, 27] +@end example +@end cartouche + + + @node GNU Free Documentation License @appendix GNU Free Documentation License @include fdl.texinfo |
