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

Consider std::move-ing callbacks into the command list instead of const references #41

Open
nickolasrossi opened this issue Jun 27, 2019 · 0 comments

Comments

@nickolasrossi
Copy link

Because the callbacks are passed in as const references, the final step where the callback is inserted into the command queue results in a copy. This is expensive if the callback is a functor object with a lot of state.

m_commands.push({redis_cmd, callback});

If the callbacks were instead passed by value, and forwarded into the command queue via std::move, C++17 copy elision would eliminate the copies.

m_commands.emplace(redis_cmd, std::move(callback));

This sort of thing is typical with asio callbacks and could be applied here as well.

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

No branches or pull requests

1 participant