Use perfect forwarding in templates where possible

This commit is contained in:
Robbert van der Helm
2021-05-17 01:02:45 +02:00
parent 883b6b7700
commit e974d1d2b1
5 changed files with 31 additions and 31 deletions
@@ -138,8 +138,8 @@ class Vst3PlugViewProxyImpl : public Vst3PlugViewProxy {
* @see Vst3HostBridge::send_mutually_recursive_message
*/
template <typename T, typename F>
T run_gui_task(F f) {
std::packaged_task<T()> do_call(std::move(f));
T run_gui_task(F fn) {
std::packaged_task<T()> do_call(std::move(fn));
std::future<T> do_call_response = do_call.get_future();
// If `Vst3Bridge::send_mutually_recursive_message()` is currently being
+2 -2
View File
@@ -210,13 +210,13 @@ class Vst3PluginBridge : PluginBridge<Vst3Sockets<std::jthread>> {
* @see Vst3PlugViewProxyImpl::run_gui_task
*/
template <typename F>
bool maybe_run_on_mutual_recursion_thread(F& cb) {
bool maybe_run_on_mutual_recursion_thread(F& fn) {
// We're handling an `F&` here because we cannot copy a
// `packged_task()`, and we need to be able to move that actual task
std::unique_lock mutual_recursion_lock(mutual_recursion_contexts_mutex);
if (!mutual_recursion_contexts.empty()) {
boost::asio::dispatch(*mutual_recursion_contexts.back(),
std::move(cb));
std::move(fn));
return true;
} else {
return false;