From a8259cf1e54830287aeac0b1c6bec46d8696bbbd Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 7 Mar 2014 23:24:21 +0100 Subject: info: concurrently MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- info/join-python.texinfo | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'info') 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 -- cgit v1.2.3-70-g09d2