#!/usr/bin/env php receive()); print "Sleeping for 3 seconds...\n"; sleep(3); // Blocking call in thread. yield from $this->send('Data sent from child.'); print "Sleeping for 2 seconds...\n"; sleep(2); // Blocking call in thread. return 42; }); print "Waiting 2 seconds to send start data...\n"; yield Coroutine\sleep(2); yield from $context->send('Start data'); printf("Received the following from child: %s\n", yield from $context->receive()); printf("Thread ended with value %d!\n", yield from $context->join()); })->cleanup([$timer, 'stop'])->done(); Loop\run();