Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sysread/ipc-pleather
Easy to use concurrency primitives for Perl, inspired by Cilk
https://github.com/sysread/ipc-pleather
Last synced: about 1 month ago
JSON representation
Easy to use concurrency primitives for Perl, inspired by Cilk
- Host: GitHub
- URL: https://github.com/sysread/ipc-pleather
- Owner: sysread
- Created: 2017-11-11T22:13:51.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-11-14T12:32:16.000Z (about 7 years ago)
- Last Synced: 2023-08-20T22:14:32.622Z (over 1 year ago)
- Language: Perl
- Size: 9.77 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.pod
- Changelog: Changes
Awesome Lists containing this project
README
=pod
=encoding UTF-8
=head1 NAME
IPC::Pleather - Easy to use concurrency primitives inspired by Cilk
=head1 VERSION
version 0.02
=head1 SYNOPSIS
use IPC::Pleather;
sub fib {
my $n = shift;
return $n if $n < 2;spawn my $x = fib($n - 1);
spawn my $y = fib($n - 2);sync $x;
sync $y;return $x + $y;
}=head1 DESCRIPTION
C has L, Perl has Pleather.
IPC::Pleather adopts two keywords from Cilk, C and C. C
signals that the block or expression I be executed concurrently. C
denotes a merge point, waiting until the spawned expression is completely
resolved.=head1 KEYWORDS
=head2 spawn
Declares a variable whose value may or may not be executed in a forked process.
Some care is taken to guarantee a fixed cap on the total number of forks.
Recursive calls to spawn via the spawned expression (as in the Fibonacci
example in the L) are bound by the same maximum.The forking mechanism is implemented using L,
allowing the maximum number of processes to be controlled either by setting
C<$AnyEvent::Util::MAX_FORKS> or with the C
environmental variable.C accepts several different expression syntaxes.
# Block with optional arguments
spawn my $var = {...} $arg1, $arg2, $arg3;# Subroutine call
spawn my $var = do_stuff($arg1, $arg1 + $arg2, ...);The latter syntax expands to the former, and all expressions in the argument
list are evaluated in the subprocess (or not, as the case may be), rather than
in the process from which they were spawned.=head2 sync
Causes the process to block until the specified variable is fully resolved.
For spawned variables which executed in a forked process, a L is used to synchronize the result. When
executed locally, the result is immediately assigned to the variable and the
call to C is essentially a no-op.=head1 SEE ALSO
=over
=item L
=back
=head1 AUTHOR
Jeff Ober
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2017 by Jeff Ober.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.=cut