Skip to content

Inline Sender into Address - #141

Closed
thomaseizinger wants to merge 8 commits into
masterfrom
inline-sender
Closed

Inline Sender into Address#141
thomaseizinger wants to merge 8 commits into
masterfrom
inline-sender

Conversation

@thomaseizinger

@thomaseizinger thomaseizinger commented Jul 17, 2022

Copy link
Copy Markdown
Collaborator

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
Comment thread src/broadcast_future.rs
Inner::Initial {
message, sender, ..
message,
chan: sender,

Copy link
Copy Markdown
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.

@thomaseizinger
thomaseizinger requested a review from Restioson July 18, 2022 10:43
@Restioson

Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread src/inbox/tx.rs
New {
msg: SentMessage<A>,
tx: Sender<A, Rc>,
chan: Arc<Chan<A>>,

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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! :)

@Restioson Restioson left a comment

Copy link
Copy Markdown
Owner

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

Comment thread src/address.rs
ord => ord,
})
Some(
match Arc::as_ptr(&self.inner).cmp(&Arc::as_ptr(&other.inner)) {

Copy link
Copy Markdown
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
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@Restioson Restioson Jul 18, 2022

Copy link
Copy Markdown
Owner

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
Copy Markdown
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
Copy Markdown
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