<commit_before>=begin pod

=TITLE class Channel

=SUBTITLE Thread-safe queue for sending values from producers to consumers

    class Channel { ... }

A Channel is a thread-safe queue that helps you to send a series of objects from
one or more producers to one or more consumers.

    my $c = Channel.new;
    await (^10).map: {
        start {
            my $r = rand;
            sleep $r;
            $c.send($r);
        }
    }
    $c.close;
    say $c.list;

=head1 Methods

=head2 method send

    method send(Channel:D: \item)

Enqueues an item into the channel. Throws an exception of type
C<X::Channel::SendOnClosed> if the channel has been closed already.

=head2 method receive

    method receive(Channel:D:)

Receives and removes an item from the channel. It blocks if no item is
present, waiting for a C<send> from another thread.

Throws an exception of
type C<X::Channel::ReceiveOnClose> if the channel has been closed, and the
last item has been removed already.

If the channel has been marked as erratic with method C<fail>, and the last
item has been removed, throws the argument that was given to C<fail> as an
exception.

See method C<poll> for a non-blocking version that won't throw exceptions.

=head2 method poll

    method poll(Channel:D:)

Receives and removes an item from the channel. If no item is present, returns
C<Nil> instead of waiting.<commit_msg>Fix the name of the X::Channel::ReceiveOnClosed<commit_after>=begin pod

=TITLE class Channel

=SUBTITLE Thread-safe queue for sending values from producers to consumers

    class Channel { ... }

A Channel is a thread-safe queue that helps you to send a series of objects from
one or more producers to one or more consumers.

    my $c = Channel.new;
    await (^10).map: {
        start {
            my $r = rand;
            sleep $r;
            $c.send($r);
        }
    }
    $c.close;
    say $c.list;

=head1 Methods

=head2 method send

    method send(Channel:D: \item)

Enqueues an item into the channel. Throws an exception of type
C<X::Channel::SendOnClosed> if the channel has been closed already.

=head2 method receive

    method receive(Channel:D:)

Receives and removes an item from the channel. It blocks if no item is
present, waiting for a C<send> from another thread.

Throws an exception of
type C<X::Channel::ReceiveOnClosed> if the channel has been closed, and the
last item has been removed already.

If the channel has been marked as erratic with method C<fail>, and the last
item has been removed, throws the argument that was given to C<fail> as an
exception.

See method C<poll> for a non-blocking version that won't throw exceptions.

=head2 method poll

    method poll(Channel:D:)

Receives and removes an item from the channel. If no item is present, returns
C<Nil> instead of waiting.
{'fraction_non_alphanumeric': 0.07186054784774101, 'fraction_numerical': 0.004268943436499467, 'mean_word_length': 3.2222222222222223, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '7350528', 'n_tokens_mistral': 834, 'n_tokens_neox': 798, 'n_words': 392}