Skip to content

Commit

Permalink
doc(async): Document Async component
Browse files Browse the repository at this point in the history
Signed-off-by: azjezz <azjezz@protonmail.com>
  • Loading branch information
azjezz committed Dec 22, 2022
1 parent 981769f commit e9598c5
Show file tree
Hide file tree
Showing 9 changed files with 2,023 additions and 12 deletions.
7 changes: 6 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@
Any edits to it will likely be lost.
-->

# Components

* [Psl\Async](../src/Psl/Async/README.md)

---

# Components API

- [Psl](./component/psl.md)
- [Psl\Async](./component/async.md)
- [Psl\Channel](./component/channel.md)
- [Psl\Class](./component/class.md)
- [Psl\Collection](./component/collection.md)
Expand Down
1 change: 0 additions & 1 deletion docs/documenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ function get_all_components(): array
{
$components = [
'Psl',
'Psl\\Async',
'Psl\\Channel',
'Psl\\Class',
'Psl\\Collection',
Expand Down
6 changes: 6 additions & 0 deletions docs/templates/README.template.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
Any edits to it will likely be lost.
-->

# Components

* [Psl\Async](../src/Psl/Async/README.md)

---

# Components API

{{ list }}
3 changes: 1 addition & 2 deletions src/Psl/Async/Awaitable.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct(State $state)
}

/**
* Iterate over the given awaitables in completion order.
* Iterate over the given `Awaitable`s in completion order.
*
* @template Tk
* @template Tv
Expand Down Expand Up @@ -125,7 +125,6 @@ public function isComplete(): bool
return $this->state->isComplete();
}


/**
* {@inheritDoc}
*
Expand Down
9 changes: 5 additions & 4 deletions src/Psl/Async/KeyedSemaphore.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
/**
* Run an operation with a limit on number of ongoing asynchronous jobs for a specific key.
*
* All operations must have the same input type (Tin) and output type (Tout), and be processed by the same function;
* All operations must have the same input type (Tin) and output type (Tout), and be processed by the same function.
*
* `Tin` may be a callable invoked by the `$operation` for maximum flexibility,
* however this pattern is best avoided in favor of creating semaphores with a more narrow process.
*
Expand Down Expand Up @@ -47,15 +48,15 @@ final class KeyedSemaphore
* @param (Closure(Tk, Tin): Tout) $operation
*/
public function __construct(
private int $concurrencyLimit,
private Closure $operation,
private readonly int $concurrencyLimit,
private readonly Closure $operation,
) {
}

/**
* Run the operation using the given `$input`.
*
* If the concurrency limit has been reached, this method will wait until one of the ingoing operations has completed.
* If the concurrency limit has been reached for the given `$key`, this method will wait until one of the ingoing operations has completed.
*
* @param Tk $key
* @param Tin $input
Expand Down
2 changes: 1 addition & 1 deletion src/Psl/Async/KeyedSequence.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ final class KeyedSequence
* @param (Closure(Tk, Tin): Tout) $operation
*/
public function __construct(
private Closure $operation,
private readonly Closure $operation,
) {
}

Expand Down
Loading

0 comments on commit e9598c5

Please sign in to comment.