Skip to content

Commit

Permalink
Complement description in section of Mutex drivers in readme (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
devanych committed Aug 9, 2021
1 parent f9f1e0f commit e100c53
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Expand Up @@ -91,6 +91,29 @@ If you want to provide your own driver, you need to implement `MutexFactoryInter
There is ready to extend `MutexFactory` and a `RetryAcquireTrait` that contains `retryAcquire()` method implementing
the "wait for a lock for a certain time" functionality.

When implementing your own drivers, you need to take care of automatic unlocking. For example using a destructor:

```php
public function __destruct()
{
$this->release();
}
```

and shutdown function:

```php
public function __construct()
{
register_shutdown_function(function () {
$this->release();
});
}
```

Note that you should not call the `exit()` or `die()` functions in the destructor or shutdown function. Since calling
these functions in the destructor and shutdown function will prevent all subsequent completion functions from executing.

## Testing

### Unit testing
Expand Down

0 comments on commit e100c53

Please sign in to comment.