phasync
Claim / release

Method

Claim::release

Give the claim up, so that another can take it.

Description#

public Claim::release(): void

Does nothing when this handle holds nothing.

Examples#

Example 1Release before the handle goes
use Swerve\Swerve;

phasync::run(function () {
    $claim = Swerve::claim('leader');
    $claim->acquire();
    echo 'held: ', var_export($claim->held(), true), "\n";

    $claim->release();                       // give it up while the handle lives on
    echo 'held: ', var_export($claim->held(), true), "\n";
    echo 'available: ', var_export($claim->available(), true), "\n";

    $claim->release();                       // releasing what is not held does nothing
});
Output
held: true
held: false
available: true

See also#

  • Claim::acquireTake the name, trying every 20 ms for up to $timeout seconds when another holds it.