<commit_before>#!/usr/bin/env php
<?php
require dirname(__DIR__).'/vendor/autoload.php';

use Amp\Loop;
use Amp\Parallel\Threading\Thread;
use Amp\Pause;

Loop::run(function () {
    $timer = Loop::repeat(1000, function () {
        static $i;
        $i = $i ? ++$i : 1;
        print "Demonstrating how alive the parent is for the {$i}th time.\n";
    });

    try {
        // Create a new child thread that does some blocking stuff.
        $context = Thread::spawn(function () {
            printf("\$this: %s\n", get_class($this));

            printf("Received the following from parent: %s\n", yield $this->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());<commit_msg>rename Pause to Delayed<commit_after>#!/usr/bin/env php
<?php
require dirname(__DIR__).'/vendor/autoload.php';

use Amp\Loop;
use Amp\Parallel\Threading\Thread;
use Amp\Delayed;

Loop::run(function () {
    $timer = Loop::repeat(1000, function () {
        static $i;
        $i = $i ? ++$i : 1;
        print "Demonstrating how alive the parent is for the {$i}th time.\n";
    });

    try {
        // Create a new child thread that does some blocking stuff.
        $context = Thread::spawn(function () {
            printf("\$this: %s\n", get_class($this));

            printf("Received the following from parent: %s\n", yield $this->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 Delayed(2000);

        yield $context->send("Start data");

        printf("Received the following from child: %s\n", yield $context->receive());
{'fraction_non_alphanumeric': 0.1507321274763135, 'fraction_numerical': 0.013781223083548665, 'mean_word_length': 2.1734972677595628, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7204081', 'n_tokens_mistral': 730, 'n_tokens_neox': 666, 'n_words': 212}