#!/usr/bin/env php receive()); print "Sleeping for 3 seconds...\n"; sleep(3); // Blocking call in thread. yield $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 new Pause(2000); yield $context->send("Start data"); printf("Received the following from child: %s\n", yield $context->receive()); printf("Thread ended with value %d!\n", yield $context->join()); } finally { Loop::cancel($timer); } });