Skip to content

Commit

Permalink
Add custom MutexRuntimeException
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-ivanov committed Nov 12, 2020
1 parent 34b6616 commit d15f55e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
9 changes: 9 additions & 0 deletions src/MutexRuntimeException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace Illuminated\Console;

use RuntimeException;

class MutexRuntimeException extends RuntimeException
{
}
7 changes: 3 additions & 4 deletions src/WithoutOverlapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Illuminated\Console;

use RuntimeException;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

Expand All @@ -19,15 +18,15 @@ protected function initializeMutex()
{
$mutex = new Mutex($this);
if (!$mutex->acquireLock($this->getMutexTimeout())) {
throw new RuntimeException('Command is running now!');
throw new MutexRuntimeException('Command is running now!');
}

register_shutdown_function([$this, 'releaseMutexLock'], $mutex);
}

public function getMutexStrategy()
{
return (property_exists($this, 'mutexStrategy') ? $this->mutexStrategy : 'file');
return property_exists($this, 'mutexStrategy') ? $this->mutexStrategy : 'file';
}

public function setMutexStrategy($strategy)
Expand All @@ -37,7 +36,7 @@ public function setMutexStrategy($strategy)

public function getMutexTimeout()
{
return (property_exists($this, 'mutexTimeout') ? $this->mutexTimeout : 0);
return property_exists($this, 'mutexTimeout') ? $this->mutexTimeout : 0;
}

public function setMutexTimeout($timeout)
Expand Down

0 comments on commit d15f55e

Please sign in to comment.