-
Notifications
You must be signed in to change notification settings - Fork 36
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
Inline Sender
into Address
#141
Conversation
a794e59
to
91e48f5
Compare
@@ -47,11 +43,13 @@ where | |||
pub fn priority(self, priority: u32) -> Self { | |||
match self.inner { | |||
Inner::Initial { | |||
message, sender, .. | |||
message, | |||
chan: sender, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self: Remove this extra binding.
I think that this would cause unintuitive behaviour. For instance, I'd expect the following to always send: let addr: Address<MyActor, Strong> = addr; // just asserting this for test purposes
tokio::task::spawn(addr.send(MyMessage));
drop(addr); |
Fair enough, so we need to keep a strong reference around in the |
New { | ||
msg: SentMessage<A>, | ||
tx: Sender<A, Rc>, | ||
chan: Arc<Chan<A>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we should just replace this with tx
again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean the variable name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean instead of holding the inner channel, we can just clone the sender, which is just chan + rc, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no more Sender
with this PR :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, right! It would be Address
then, I guess!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we could embed the Address
yeah. Although that would be a cyclic dependency. It is not a problem but conceptually weird.
I am doing some other work on SendFuture
atm so I'll go think about this once that is done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How exactly is it a circular dependency? Do you mean in terms of logic?
I am doing some other work on SendFuture atm so I'll go think about this once that is done.
Sure, no problem, and thanks! :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Just those two things that I mentioned to address now
ord => ord, | ||
}) | ||
Some( | ||
match Arc::as_ptr(&self.inner).cmp(&Arc::as_ptr(&other.inner)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to check, does this properly compare data ptrs and not vtables?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the docs, yes: https://doc.rust-lang.org/std/sync/struct.Arc.html#method.ptr_eq
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ptr::eq
has this same issue, as far as I know. as_ptr
might explicitly return the data ptr, but it might also return *const dyn _
, which would not be enough to ensure data equality is being tested. See rust-lang/rust#80505 for more
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, I guess this also needs to be changed then.
I am going to close this for now, want to get some of the internal channel refactorings over the line first. |
Another step towards #126.
What is interesting about this patch-set is that it removes the reference count from
SendFuture
andBroadcastFuture
. I think this is okay?