Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReceivePort and SendPort should be generic #23059

Closed
DartBot opened this issue Apr 1, 2015 · 5 comments
Closed

ReceivePort and SendPort should be generic #23059

DartBot opened this issue Apr 1, 2015 · 5 comments
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-not-planned Closed as we don't intend to take action on the reported issue library-isolate type-enhancement A request for a change that isn't a bug

Comments

@DartBot
Copy link

DartBot commented Apr 1, 2015

This issue was originally filed by bl...@google.com


abstract class ReceivePort<T> implements Stream<T>
and likewise
'abstract class SendPort<T> implements Capability`

There are no backwards compatibility issues because ReceivePort and SendPort will keep behaving as is.

@sethladd
Copy link
Contributor

sethladd commented Apr 1, 2015

Removed Type-Defect label.
Added Type-Enhancement, Library-Isolate, Area-Library, Triaged labels.

@lrhn
Copy link
Member

lrhn commented Apr 7, 2015

This seems like a slam-dunk on the surface, but there is a problem with adding a type parameter to SendPort.

SendPort objects can themselves be sent to any another isolate, either as isolate spawn parameters or through other send ports, but Type objects can't. If a SendPort has a type parameter, it implicitly contains a reference to that type, and then the SendPort can't be sent to, or through, another isolate that isn't equivalent to the current one (hasn't been created using only Isolate.spawn from the same original isolate, as opposed to an isolate created using Isolate.spawnUri).

We don't want to make "clever" restrictions like "a SendPort<X>" can be sent to any Isolate if X is a type in dart:core or dart:isolate, but otherwise it can only be sent to equivalent isolates". Likewise for only allowing SendPort<dynamic> to be sent to non-equivalent isolates.

One option is to lose the type parameter, which would mean defaulting it to dynamic, when the SendPort is sent to a non-equivalent isolate. That is doable, but still somewhat counter to the idea of having the type parameter, and it would look odd if the SendPort was sent back to the original isolate without the type parameter.

@lrhn
Copy link
Member

lrhn commented Apr 7, 2015

Also, if the SendPort loses the type parameter, then it's possible to send a value that has the wrong type when it is received. That would either mean a type error on the receiving end, which is either lost or passed on the ReceivePort stream - and a ReceivePort doesn't otherwise have errors.
It's not clear what would happen for a RawReceivePort<T> if it receives a non-T value.

All in all, I don't think it's wort the compllication.

@DartBot
Copy link
Author

DartBot commented Apr 7, 2015

This comment was originally written by @kaendfinger


I agree with @­lrn, this could have bad consequences.

@lrhn
Copy link
Member

lrhn commented Apr 9, 2015

Not going to make this change right now.
If we come up with a good solution for the problems, we might revisit the idea.


Added NotPlanned label.

@DartBot DartBot added Type-Enhancement library-isolate area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-not-planned Closed as we don't intend to take action on the reported issue labels Apr 9, 2015
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed priority-unassigned labels Mar 1, 2016
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-not-planned Closed as we don't intend to take action on the reported issue library-isolate type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants