Async-Stream

 view release on metacpan or  search on metacpan

lib/Async/Stream/Pushable.pm  view on Meta::CPAN

					$return_cb->();
				}
				else {
					push @{ $self->{_requests} }, $return_cb;	
				}
			}
		},
		@_,
	);

	$self->{_items}        = [];
	$self->{_requests}     = [];
	$self->{_is_finalized} = 0;

	return $self;
}

=head2 push(@new_items)

Push new items to stream

  my $stream->push(@new_items);

=cut
sub push {
	my ($self, @new_items) = @_;

	croak q{The stream is finalized} if ($self->{_is_finalized});

	while (@{ $self->{_requests} }) {
		my $return_cb = shift @{ $self->{_requests} };
		$return_cb->( shift @new_items );
	}

	if (@new_items) {
		push @{ $self->{_items} }, @new_items; 
	}

	return $self;
}

=head2 finalize()

Finalize stream

  my $stream->finalize;

=cut
sub finalize {
	my ($self) = @_;

	croak q{The stream has already been finalized} if ($self->{_is_finalized});

	$self->{_is_finalized} = 1;
}

=head1 AUTHOR

Kirill Sysoev, C<< <k.sysoev at me.com> >>

=head1 BUGS AND LIMITATIONS

Please report any bugs or feature requests to 
L<https://github.com/pestkam/p5-Async-Stream/issues>.

=head1 SUPPORT

You can find documentation for this module with the perldoc command.

  perldoc Async::Stream::Item


=head1 LICENSE AND COPYRIGHT

Copyright 2017 Kirill Sysoev.

This program is free software; you can redistribute it and/or modify it
under the terms of the the Artistic License (2.0). You may obtain a
copy of the full license at:

L<http://www.perlfoundation.org/artistic_license_2_0>
=cut

1; # End of Async::Stream::Pushable



( run in 2.667 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )