. * * @package LibreNMS * @link http://librenms.org * @copyright 2017 Tony Murray * @author Tony Murray */ namespace LibreNMS\Interfaces; interface Lock { /** * Release the lock. */ public function release(); /** * Given a lock name, try to acquire the lock. * On success return a Lock object, or on failure return false. * @param string $lock_name Name of lock * @param int $wait Try for this many seconds to see if we can acquire the lock. Default is no wait. A negative timeout will wait forever. * @return \LibreNMS\Interfaces\Lock|false */ public static function lock($lock_name, $wait = 0); /** * Renew an expiring lock * * @param int $expiration number of seconds to hold lock for (null to cancel expiration) */ public function renew($expiration); /** * Given a lock name, try to acquire the lock, exiting on failure. * On success return a Lock object. * @param string $lock_name Name of lock * @param int $timeout Try for this many seconds to see if we can acquire the lock. Default is no wait. A negative timeout will wait forever. * @return \LibreNMS\Interfaces\Lock */ public static function lockOrDie($lock_name, $timeout = 0); }