Channel
Stream aware, multiple producer, single consumer closeable channel.
- Companion
- object
class Object
trait Matchable
class Any
Value members
Methods
Sends all the elements of the input stream through this channel,
and closes it after.
Especially useful if the channel is single producer.
and closes it after.
Especially useful if the channel is single producer.
Sends an element through this channel.
It can be called concurrently by multiple producers, and it may
semantically block if the channel is bounded or synchronous.
semantically block if the channel is bounded or synchronous.
No-op if the channel is closed, see close for further info.
This method CANNOT be called concurrently by multiple consumers, if
you do so, one of the consumers might become permanently
deadlocked.
you do so, one of the consumers might become permanently
deadlocked.
It is possible to call
one has terminated, but be aware that some element might get lost
in the process, e.g if the first call to
the channel, and terminated after emitting 2, when the second call
to
stream
again once the previousone has terminated, but be aware that some element might get lost
in the process, e.g if the first call to
stream
got 5 elements offthe channel, and terminated after emitting 2, when the second call
to
stream
starts it won't see those 3 elements.Every time
are queued up in a single chunk, including those from producers
that might be semantically blocked on a bounded channel, which will
then become unblocked. That is, a bound on a channel represents
the maximum number of elements that can be queued up before a
producer blocks, and not the maximum number of elements that will
be received by
stream
is pulled, it will serve all the elements thatare queued up in a single chunk, including those from producers
that might be semantically blocked on a bounded channel, which will
then become unblocked. That is, a bound on a channel represents
the maximum number of elements that can be queued up before a
producer blocks, and not the maximum number of elements that will
be received by
stream
at once.This method achieves graceful shutdown: when the channel gets
closed,
currently enqueued elements, including the ones by producers blocked
on a bound.
closed,
stream
will terminate naturally after consuming allcurrently enqueued elements, including the ones by producers blocked
on a bound.
"Termination" here means that
wait for new elements on the channel, and not that it will be
interrupted while performing another action: if you want to
interrupt
elements, you should use
stream
will no longerwait for new elements on the channel, and not that it will be
interrupted while performing another action: if you want to
interrupt
stream
immediately, without first processing enqueuedelements, you should use
interruptWhen
on it instead.After a call to
will be no-ops.
close
, any further calls to send
or close
will be no-ops.
Note that
might be blocked on a bound, they will only become unblocked if
close
does not automatically unblock producers whichmight be blocked on a bound, they will only become unblocked if
stream
is executing.In other words, if
executing, blocked producers will eventually become unblocked,
before
no-ops.
However, if
because it was interrupted, or had a
producers will stay blocked unless they get explicitly
unblocked, either by a further call to
channel, or by a a
close
is called while stream
isexecuting, blocked producers will eventually become unblocked,
before
stream
terminates and further send
calls becomeno-ops.
However, if
close
is called after stream
has terminated (e.gbecause it was interrupted, or had a
.take(n)
), then blockedproducers will stay blocked unless they get explicitly
unblocked, either by a further call to
stream
to drain thechannel, or by a a
race
with closed
.