Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update README to document close and fail behavior.
  • Loading branch information
gotoexit committed Feb 1, 2016
1 parent 850a753 commit 7cc4390
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion README.md
Expand Up @@ -18,18 +18,33 @@ an alternative with size limits.

$val=$bc.poll;

$bc.close;

# OR

$bc.fail(X::SomeException.new);

## Overview

The normal Perl 6 Channel class is an unbounded queue. It will grow
indefinitely as long as values are fed in and not removed. In some cases
that may not be desirable. BoundedChannel is a subclass of Channel
with a set size limit. It behaves just like Channel, with two exceptions:
with a set size limit. It behaves just like Channel, with some exceptions:

* The send method will block, if the Channel is already populated with
the maximum number of elements.
* There is a new offer method, which is the send equivalent of poll - i.e. a
non-blocking send. It returns Nil if the Channel is full, otherwise it
returns the offered value.
* If one or more threads is blocking on a send, and the channel is closed,
those send calls will throw exceptions, just as if send had been called on
a closed normal Channel.

The fail method is an exception to the BoundedChannel limit. If the
BoundedChannel is full, and fail is called, the exception specified will
still be placed at the end of the queue, even if that would violate
the limit. This was deemed acceptable to avoid having a fail contend with
blocking send calls.

## BoundedChannel

Expand Down

0 comments on commit 7cc4390

Please sign in to comment.