Giter VIP home page Giter VIP logo

ipc-pleather's People

Contributors

sysread avatar

Stargazers

 avatar

Watchers

 avatar  avatar

ipc-pleather's Issues

Fix for recursion

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.