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

Inline Sender into Address #141

Closed
wants to merge 8 commits into from
Closed

Inline Sender into Address #141

wants to merge 8 commits into from

Conversation

thomaseizinger
Copy link
Collaborator

@thomaseizinger thomaseizinger commented Jul 17, 2022

Another step towards #126.

What is interesting about this patch-set is that it removes the reference count from SendFuture and BroadcastFuture. I think this is okay?

@thomaseizinger thomaseizinger requested review from Restioson and removed request for Restioson July 17, 2022 19:09
Base automatically changed from channel-refactoring to master July 18, 2022 06:59
@thomaseizinger thomaseizinger marked this pull request as ready for review July 18, 2022 10:41
@@ -47,11 +43,13 @@ where
pub fn priority(self, priority: u32) -> Self {
match self.inner {
Inner::Initial {
message, sender, ..
message,
chan: sender,
Copy link
Collaborator Author

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.

@Restioson
Copy link
Owner

What is interesting about this patch-set is that it removes the reference count from SendFuture and BroadcastFuture. I think this is okay?

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);

@thomaseizinger
Copy link
Collaborator Author

What is interesting about this patch-set is that it removes the reference count from SendFuture and BroadcastFuture. I think this is okay?

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 SendFuture.

New {
msg: SentMessage<A>,
tx: Sender<A, Rc>,
chan: Arc<Chan<A>>,
Copy link
Owner

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?

Copy link
Collaborator Author

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?

Copy link
Owner

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?

Copy link
Collaborator Author

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 :)

Copy link
Owner

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!

Copy link
Collaborator Author

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.

Copy link
Owner

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! :)

Copy link
Owner

@Restioson Restioson left a 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)) {
Copy link
Owner

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Owner

@Restioson Restioson Jul 18, 2022

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

Copy link
Collaborator Author

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.

@thomaseizinger
Copy link
Collaborator Author

I am going to close this for now, want to get some of the internal channel refactorings over the line first.

@thomaseizinger thomaseizinger deleted the inline-sender branch August 2, 2022 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants