You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now every mutex driver must release mutex manually if option autocommit set on true.
This decision not only adds difficulties in implementing the new driver, but also does not eliminate problems when managing the mutex.
Imagine that you have some acquired mutex:
$fileMutexFactory = newFileMutexFactory(__DIR__ . '/var/mutexes', false);
$mutex = $this->mutexes->create('some_mutex');
// some actions$this->doSomething(); // But there will be exception$mutex->release();
Such mutex will not be released because autocommit turn off.
I think, mutex releaser must be required and do not rely on the user's actions. Every mutex implementation must release mutex anyway in they destructor's.
The following code will guarantees that the mutex will be released anyway on the script shutdown, and it also does not require drivers to implement it themselves.
abstractclassMutex
{
/** * Acquires a lock. * * @param int $timeout Time (in seconds) to wait for lock to be released. Defaults to zero meaning that method * will return false immediately in case lock was already acquired. */abstractpublicfunctionacquire(int$timeout = 0): bool;
/** * Releases a lock. */abstractpublicfunctionrelease(): void;
abstractpublicfunctionreleased(): bool;
finalpublicfunction__destruct()
{
if (!$this->released()) {
$this->release();
}
}
}
After that, we can delete the call to the register_shutdown_function function and the `autocommit' option.
The text was updated successfully, but these errors were encountered:
Now every mutex driver must release mutex manually if option
autocommit
set on true.This decision not only adds difficulties in implementing the new driver, but also does not eliminate problems when managing the mutex.
Imagine that you have some acquired mutex:
Such mutex will not be released because
autocommit
turn off.I think, mutex releaser must be required and do not rely on the user's actions. Every mutex implementation must release mutex anyway in they destructor's.
The following code will guarantees that the mutex will be released anyway on the script shutdown, and it also does not require drivers to implement it themselves.
After that, we can delete the call to the
register_shutdown_function
function and the `autocommit' option.The text was updated successfully, but these errors were encountered: