method with-lock-hidden-from-recursion-check

Documentation for method with-lock-hidden-from-recursion-check assembled from the following types:

class Lock::Async

From Lock::Async

(Lock::Async) method with-lock-hidden-from-recursion-check

Defined as:

method with-lock-hidden-from-recursion-check(&code)

Temporarily resets the Lock::Async recursion list so that it no longer includes the lock this method is called on and runs the given &code immediately if the call to the method occurred in a caller chain where protect-or-queue-on-recursion has already been called and the lock has been placed on the recursion list.

my Lock::Async $lock .= new;
my Int         $count = 0;
 
$lock.protect-or-queue-on-recursion({
    my Int $count = 0;
 
    # Runs instantly. 
    $lock.with-lock-hidden-from-recursion-check({
        $count++;
    });
 
    # Runs after the outer caller's protect-or-queue-on-recursion call has 
    # finished running. 
    $lock.protect-or-queue-on-recursion({
        $count++;
    }).then({
        say $count# OUTPUT: 2 
    });
 
    say $count# OUTPUT: 1 
});