Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(channel): introduce new channel component #283

Merged
merged 1 commit into from
Nov 23, 2021
Merged

Conversation

azjezz
Copy link
Owner

@azjezz azjezz commented Nov 23, 2021

Inspired by async_std::channel module, The Channel component provides asynchronous channels for communication between different component of an application.

e.g:

use Psl\Async;
use Psl\Channel;

/**
 * @var Channel\ReceiverInterface<string> $receiver
 * @var Channel\SenderInterface<string> $sender
 */
[$receiver, $sender] = Channel\bounded(2);

Async\Scheduler::defer(function() use($sender) {
  Async\sleep(1); // sleep for a second.

  $sender->send('hello');
});

$message = $receiver->receive(); // 'hello'

Signed-off-by: azjezz <azjezz@protonmail.com>
@azjezz azjezz added Priority: Medium This issue may be useful, and needs some attention. Status: Completed Nothing further to be done with this issue. Awaiting to be closed by the requestor out of politeness Type: Enhancement Most issues will probably ask for additions or changes. labels Nov 23, 2021
@azjezz azjezz added this to the 2.0.0 milestone Nov 23, 2021
@azjezz azjezz self-assigned this Nov 23, 2021
@coveralls
Copy link

Pull Request Test Coverage Report for Build 1496391738

  • 92 of 92 (100.0%) changed or added relevant lines in 10 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 1493967235: 0.0%
Covered Lines: 3297
Relevant Lines: 3297

💛 - Coveralls

@azjezz azjezz merged commit 23a5a61 into 2.0.x Nov 23, 2021
@azjezz azjezz deleted the feat/channel branch November 23, 2021 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: Medium This issue may be useful, and needs some attention. Status: Completed Nothing further to be done with this issue. Awaiting to be closed by the requestor out of politeness Type: Enhancement Most issues will probably ask for additions or changes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants