-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Introduce job property for channels #260
Comments
A tiny consideration: the Error: |
@fvasco Thanks for
Also note, that we are looking for a common nomenclature between regular (object) channels and byte-channels that are work-in-progress in In order for the
|
This looks interesting, in such case we should consider to implement nonblocking, blocking and select clause methods ( |
I am considering this as an opportunity to introduce a Other consideration is to introduce an (optional?) |
@fvasco If we add |
The CLOSE token is received, so the channel has not pending actions. |
@fvasco This can be done, but it would have a different semantics with actors, since when you wait for an actor's job you wait not just until it receives the close token, but until it actually processes close token. |
Not only, map/reduce functions should be rewritten considering the parent job. broadcastChannel
.openSubscription()
.filter { it > 10 }
.map { TooHigh(it) }
.sendTo(actor) |
@fvasco Good point. We need to cary this semantics across the whole chain of transformations. This is a strong argument in favor of adding |
The actor's job should support the |
@fvasco Lazy actors are supported now. You can do |
I intend the val actor = actor<Int>(start = CoroutineStart.LAZY) {
...
}
// other stuff
actor.job.start() |
Another argument in favor of adding a |
Another use-case just popped up in public Slack:
If we have a |
Only channels created with |
All channels will have |
So the title of this issue is outdated. |
@LouisCAD it's still unclear for us which semantic If you have any considerations why |
We decided not to introduce
New actors don't expose channel but expose job, so this issue is irrelevant to them. |
When data is being consumed by an
actor
there is sometimes a need to wait until all the messages are processed after a channel was closed. Currently this requires the following code patten:The proposal is to introduce
ActorSendChannel<T>
interface that extendsSendChannel<T>
interface and introducesjob
property that directly gives access to actor's job, so that this code can be written in a slightly more straightforward way:It makes sense to also introduce
ProducerReceiveChannel
for a symmetry, albeit its usefulness is not immediately apparent at the moment.Note, that in some older version of
kotlinx.coroutines
library there ware anActorJob<T>
andProducerJob<T>
interfaces that extended bothSendChannel<T>
/ReceiveChannel<T>
andJob
. It served a similar role, but mixing both channel and job methods onto a single receiver had proved harmful (see #127). This issue basically reboots this idea, but in cleaner way, by moving job into a separate property.The text was updated successfully, but these errors were encountered: