-
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.
- Loading branch information
1 parent
df17085
commit 5acdd5a
Showing
466 changed files
with
5,691 additions
and
48,667 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,3 +41,4 @@ | |
/~ | ||
/content/phpunit/.lock | ||
/site/config | ||
/.ddev |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Amp; | ||
|
||
/** | ||
* Cancellations are simple objects that allow registering handlers to subscribe to cancellation requests. | ||
*/ | ||
interface Cancellation | ||
{ | ||
/** | ||
* Subscribes a new handler to be invoked on a cancellation request. | ||
* | ||
* This handler might be invoked immediately in case the cancellation has already been requested. Any unhandled | ||
* exceptions will be thrown into the event loop. | ||
* | ||
* @param \Closure(CancelledException) $callback Callback to be invoked on a cancellation request. Will receive a | ||
* `CancelledException` as first argument that may be used to fail the operation. | ||
* | ||
* @return string Identifier that can be used to cancel the subscription. | ||
*/ | ||
public function subscribe(\Closure $callback): string; | ||
|
||
/** | ||
* Unsubscribes a previously registered handler. | ||
* | ||
* The handler will no longer be called as long as this method isn't invoked from a subscribed callback. | ||
*/ | ||
public function unsubscribe(string $id): void; | ||
|
||
/** | ||
* Returns whether cancellation has been requested yet. | ||
*/ | ||
public function isRequested(): bool; | ||
|
||
/** | ||
* Throws the `CancelledException` if cancellation has been requested, otherwise does nothing. | ||
* | ||
* @throws CancelledException | ||
*/ | ||
public function throwIfRequested(): void; | ||
} |
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,17 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Amp; | ||
|
||
/** | ||
* Will be thrown in case an operation is cancelled. | ||
* | ||
* @see Cancellation | ||
* @see DeferredCancellation | ||
*/ | ||
class CancelledException extends \Exception | ||
{ | ||
public function __construct(?\Throwable $previous = null) | ||
{ | ||
parent::__construct("The operation was cancelled", 0, $previous); | ||
} | ||
} |
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,26 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Amp; | ||
|
||
interface Closable | ||
{ | ||
/** | ||
* Closes the resource, marking it as unusable. | ||
* Whether pending operations are aborted or not is implementation dependent. | ||
*/ | ||
public function close(): void; | ||
|
||
/** | ||
* Returns whether this resource has been closed. | ||
* | ||
* @return bool `true` if closed, otherwise `false`. | ||
*/ | ||
public function isClosed(): bool; | ||
|
||
/** | ||
* Registers a callback that is invoked when this resource is closed. | ||
* | ||
* @param \Closure():void $onClose | ||
*/ | ||
public function onClose(\Closure $onClose): void; | ||
} |
Oops, something went wrong.