diff options
| author | Mattias Andrée <maandree@operamail.com> | 2014-03-07 18:42:42 +0100 |
|---|---|---|
| committer | Mattias Andrée <maandree@operamail.com> | 2014-03-07 18:42:42 +0100 |
| commit | 73e505ddae832792f8539b54fa00e4700c747b85 (patch) | |
| tree | f8df24ff261fcd1c340d15d953ef85a045ec7782 | |
| parent | info: overview (diff) | |
| download | join-python-73e505ddae832792f8539b54fa00e4700c747b85.tar.gz join-python-73e505ddae832792f8539b54fa00e4700c747b85.tar.bz2 join-python-73e505ddae832792f8539b54fa00e4700c747b85.tar.xz | |
info: signals
Signed-off-by: Mattias Andrée <maandree@operamail.com>
| -rw-r--r-- | info/join-python.texinfo | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/info/join-python.texinfo b/info/join-python.texinfo index 0033365..af9090b 100644 --- a/info/join-python.texinfo +++ b/info/join-python.texinfo @@ -51,6 +51,7 @@ Texts. A copy of the license is included in the section entitled @menu * Overview:: Brief overview of Join Python. +* Signals:: The signal construct. * GNU Free Documentation License:: Copying and sharing this manual. @end menu @@ -68,6 +69,74 @@ almost any published concurrency pattern with explicit monitor calls. +@node Signals +@chapter Signals + +A signal it as function that runs asynchronously. It is put +in its own thread. To declare a signal, add the @code{@@signal} +decorator to a function definition or pass function to the +the constructor of the class @code{signal}. + +@cartouche +@example +>>> from join import * +>>> import time +>>> +>>> @@signal +>>> def sig(delay, value): +>>> time.sleep(delay) +>>> print(value) +>>> +>>> sig(0.25, 'first') +>>> print('last') +last +first +@end example +@end cartouche + +@cartouche +@example +>>> from join import * +>>> import time +>>> +>>> def f(delay, value): +>>> time.sleep(delay) +>>> print(value) +>>> +>>> signal(f)(0.25, 'first') +>>> print('last') +last +first +@end example +@end cartouche + +As an extension to join-calculus, signals +in Join Java can be joined with the returned +value of the function can be fetched when joined. + +@cartouche +@example +>>> from join import * +>>> import time +>>> +>>> def f(delay, value): +>>> time.sleep(delay) +>>> return value ** 2 +>>> +>>> sig = signal(f)(0.25, 2) +>>> print('between') +>>> print(sig.join()) +between +16 +@end example +@end cartouche + +In the next chapter fragments will be introduced. +If you want a signal without a fragment capability +use @code{@@puresignal} or @code{puresignal} instead +of @code{@@signal} or @code{signal}. + + @node GNU Free Documentation License @appendix GNU Free Documentation License @include fdl.texinfo |
