@@ -20,6 +20,7 @@ Prevents overlapping for Laravel console commands.
2020- [ Strategies] ( #strategies )
2121- [ Advanced] ( #advanced )
2222 - [ Common mutex for several commands] ( #common-mutex-for-several-commands )
23+ - [ Custom mutex timeout] ( #custom-mutex-timeout )
2324- [ Troubleshooting] ( #troubleshooting )
2425 - [ Trait included, but nothing happens?] ( #trait-included-but-nothing-happens )
2526 - [ Several traits conflict?] ( #several-traits-conflict )
@@ -118,6 +119,48 @@ class MyProtectedCommand extends Command
118119}
119120```
120121
122+ ### Custom mutex timeout
123+
124+ By default mutex is checking for a running command, and if it finds such - it just exits. However, you can manually set
125+ required timeout for a mutex, so it can wait for another instance to finish it' s execution, instead of just quiting immediately.
126+
127+ You can change mutex timeout by specifying ` $mutexTimeout ` field:
128+
129+ ` ` ` php
130+ class MyProtectedCommand extends Command
131+ {
132+ use WithoutOverlapping;
133+
134+ protected $mutexTimeout = 3000; // milliseconds
135+
136+ // ...
137+ }
138+ ` ` `
139+
140+ Or by using ` setMutexTimeout` method:
141+
142+ ` ` ` php
143+ class MyProtectedCommand extends Command
144+ {
145+ use WithoutOverlapping;
146+
147+ public function __construct()
148+ {
149+ parent::__construct ();
150+
151+ $this -> setMutexTimeout(3000); // milliseconds
152+ }
153+
154+ // ...
155+ }
156+ ` ` `
157+
158+ There are three possible options for ` $mutexTimeout ` field:
159+
160+ - ` 0` - check without waiting (default);
161+ - ` {milliseconds}` - check, and wait for a maximum of milliseconds specified;
162+ - ` null` - wait, till running instance finish its execution;
163+
121164# # Troubleshooting
122165
123166# ## Trait included, but nothing happens?
0 commit comments