/**
* Unlock key, locked by method 'lock_key'
* @param \Jamm\Memory\KeyAutoUnlocker $key_auto_unlocker
* @return bool
*/
public function unlock_key(\Jamm\Memory\KeyAutoUnlocker $key_auto_unlocker)
{
$key = $key_auto_unlocker->getKey();
if (empty($key)) {
$this->ReportError('Empty key in the AutoUnlocker', __LINE__);
return false;
}
$key_auto_unlocker->revoke();
if (!$this->sem->get_access_write($auto_unlocker)) {
return false;
}
$this->readmemory();
if (!isset($this->mem[self::map_keys][$key])) {
$this->ReportError('key [' . $key . '] does not exists', __LINE__);
return false;
}
if (isset($this->mem[self::map_key_locks][$key])) {
unset($this->mem[self::map_key_locks][$key]);
return $this->refresh();
}
return true;
}