-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: refactored CriticalSection
feat: added support for nonblocking mode
- Loading branch information
Showing
8 changed files
with
82 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace PetrKnap\CriticalSection; | ||
|
||
use PetrKnap\CriticalSection\Exception\CouldNotEnterCriticalSection; | ||
use PetrKnap\CriticalSection\Exception\CouldNotLeaveCriticalSection; | ||
use Throwable; | ||
|
||
/** | ||
* @template T | ||
*/ | ||
interface CriticalSectionInterface | ||
{ | ||
/** | ||
* @param callable(): T $criticalSection | ||
* @return ?T from the critical section | ||
* @throws CouldNotEnterCriticalSection | ||
* @throws CouldNotLeaveCriticalSection | ||
* @throws Throwable from the critical section | ||
*/ | ||
public function __invoke(callable $criticalSection); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace PetrKnap\CriticalSection\Exception; | ||
|
||
use RuntimeException; | ||
|
||
final class CouldNotEnterCriticalSection extends RuntimeException implements CriticalSectionException | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace PetrKnap\CriticalSection\Exception; | ||
|
||
use RuntimeException; | ||
|
||
final class CouldNotLeaveCriticalSection extends RuntimeException implements CriticalSectionException | ||
{ | ||
} |
2 changes: 1 addition & 1 deletion
2
src/CriticalSectionException.php → src/Exception/CriticalSectionException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters