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

[cmd] Undeprecate deferredProxy #7417

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

spacey-sooty
Copy link
Contributor

This changes the way deferred proxy is implemented to not use the deprecated ProxyCommand constructor.

This function serves a good purpose that should be kept IMO. The constructor was confusing but this is just good syntactic sugar over defer(() -> supplier.get().asProxy()).

This changes the way deferred proxy is implemented to not use the
deprecated ProxyCommand constructor.

This function serves a good purpose that should be kept IMO. The
constructor was confusing but this is just good syntactic sugar over
`defer(() -> supplier.get().asProxy())`.

Signed-off-by: Jade Turner <[email protected]>
@spacey-sooty spacey-sooty requested a review from a team as a code owner November 21, 2024 13:41
Copy link
Contributor

This PR modifies commands. Please open a corresponding PR in Python Commands and include a link to this PR.

return ProxyCommand(std::move(supplier)).ToPtr();
return Defer(
[supplier = std::move(supplier)]() mutable {
return ProxyCommand{std::move(supplier())}.ToPtr();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I couldn't make this work using the AsProxy decorator

Copy link
Member

Choose a reason for hiding this comment

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

Since the return of supplier() is already an rvalue, the move isn't needed.
The following should work:

return supplier().AsProxy()

(You can also pop a ToPtr there in between, but I think it's unneeded)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Oh I missed that we're dealing with a Command* and not a CommandPtr.
Never mind.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think there's a non-owning version of AsProxy(), so yes, I think this does have to be via the constructor. Maybe just add a comment explaining that so we don't forget?

@spacey-sooty
Copy link
Contributor Author

This PR modifies commands. Please open a corresponding PR in Python Commands and include a link to this PR.

Not applicable to Python.

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.

3 participants