Skip to content

Combining awaitables: awaitWithTimeout + sideEffect #129

Answered by rmcdaniel
naquad asked this question in Q&A
Discussion options

You must be logged in to vote

For this we can modify the awaitAnyCondition method from earlier.

use Exception;
use Workflow\ActivityStub;
use Workflow\SignalMethod;
use Workflow\Workflow;
use Workflow\WorkflowStub;

class TimeoutException extends Exception {}

class MySignalWorkflow extends Workflow
{
    private bool $ready1 = false;
    private bool $ready2 = false;

    #[SignalMethod]
    public function setReady1($ready1)
    {
        $this->ready1 = $ready1;
    }

    #[SignalMethod]
    public function setReady2($ready2)
    {
        $this->ready2 = $ready2;
    }

    public function execute()
    {
        try {
            $signal = yield from $this->awaitAnyCondition([
                'ready1' => fn () => $

Replies: 1 comment 10 replies

Comment options

You must be logged in to vote
10 replies
@naquad
Comment options

@rmcdaniel
Comment options

@naquad
Comment options

@rmcdaniel
Comment options

Answer selected by naquad
@naquad
Comment options

@rmcdaniel
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants