sysread / ipc-pleather Goto Github PK
View Code? Open in Web Editor NEWEasy to use concurrency primitives for Perl, inspired by Cilk
Easy to use concurrency primitives for Perl, inspired by Cilk
I came across your module recently and enjoyed reading the source. Unfortunately, the module hangs when running fib(big_number)
. I noticed that $DEPTH
is defined, but missing $MAXDEPTH
. The following small change allowed me to run fib(35)
to completion.
--- Pleather.pm.orig 2017-11-11 17:42:41.000000000 -0600
+++ Pleather.pm 2022-09-23 12:16:30.204743424 -0500
@@ -17,6 +17,11 @@
our $PID = $$;
our $SEM = IPC::Semaphore->new(IPC_PRIVATE, 1, S_IRUSR|S_IWUSR|IPC_CREAT);
our $DEPTH = 0;
+our $MAXDEPTH = int(log2($AnyEvent::Util::MAX_FORKS / 2)); # 2 spawns in block
+
+sub log2 {
+ log($_[0]) / log(2);
+}
our $SEMGUARD = guard {
$SEM->remove;
@@ -32,7 +37,7 @@
sub spawn {
my ($code, @args) = @_;
- if (!$AnyEvent::CondVar::Base::WAITING && sdec) {
+ if ($DEPTH < $MAXDEPTH && !$AnyEvent::CondVar::Base::WAITING && sdec) {
my $cv = AE::cv;
fork_call {
Thank you, for introducing me to Keyword::Declare
and Keyword::Simple
. Moreover, showcasing sset
, sdec
, and sinc
.
Blessings and grace!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.