diff --git a/src/common/communication/vst3.h b/src/common/communication/vst3.h index 56e965a0..00ce9bf4 100644 --- a/src/common/communication/vst3.h +++ b/src/common/communication/vst3.h @@ -382,7 +382,7 @@ class Vst3Sockets : public Sockets { void add_audio_processor_and_listen( size_t instance_id, std::promise& socket_listening_latch, - F cb) { + F&& cb) { { std::lock_guard lock(audio_processor_sockets_mutex); audio_processor_sockets.try_emplace( @@ -400,7 +400,7 @@ class Vst3Sockets : public Sockets { // receiving buffers for all calls. This slightly reduces the amount of // allocations in the audio processing loop. audio_processor_sockets.at(instance_id) - .template receive_messages(std::nullopt, cb); + .template receive_messages(std::nullopt, std::forward(cb)); } /** diff --git a/src/plugin/bridges/vst3-impls/plug-view-proxy.h b/src/plugin/bridges/vst3-impls/plug-view-proxy.h index 8dc0a506..ea97321e 100644 --- a/src/plugin/bridges/vst3-impls/plug-view-proxy.h +++ b/src/plugin/bridges/vst3-impls/plug-view-proxy.h @@ -138,8 +138,8 @@ class Vst3PlugViewProxyImpl : public Vst3PlugViewProxy { * @see Vst3HostBridge::send_mutually_recursive_message */ template - T run_gui_task(F f) { - std::packaged_task do_call(std::move(f)); + T run_gui_task(F fn) { + std::packaged_task do_call(std::move(fn)); std::future do_call_response = do_call.get_future(); // If `Vst3Bridge::send_mutually_recursive_message()` is currently being diff --git a/src/plugin/bridges/vst3.h b/src/plugin/bridges/vst3.h index ac8e7145..fa707ae3 100644 --- a/src/plugin/bridges/vst3.h +++ b/src/plugin/bridges/vst3.h @@ -210,13 +210,13 @@ class Vst3PluginBridge : PluginBridge> { * @see Vst3PlugViewProxyImpl::run_gui_task */ template - 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; diff --git a/src/wine-host/bridges/vst3.h b/src/wine-host/bridges/vst3.h index 74b91291..1e9f49b1 100644 --- a/src/wine-host/bridges/vst3.h +++ b/src/wine-host/bridges/vst3.h @@ -333,8 +333,8 @@ class Vst3Bridge : public HostBridge { * @see Vst3Bridge::send_mutually_recursive_message */ template - T do_mutual_recursion_on_gui_thread(F f) { - std::packaged_task do_call(std::move(f)); + T do_mutual_recursion_on_gui_thread(F fn) { + std::packaged_task do_call(std::move(fn)); std::future do_call_response = do_call.get_future(); // If the above function is currently being called from some thread, @@ -366,8 +366,8 @@ class Vst3Bridge : public HostBridge { * @see Vst3Bridge::do_mutual_recursion_on_gui_thread */ template - T do_mutual_recursion_on_off_thread(F f) { - std::packaged_task do_call(std::move(f)); + T do_mutual_recursion_on_off_thread(F fn) { + std::packaged_task do_call(std::move(fn)); std::future do_call_response = do_call.get_future(); std::unique_lock lock(mutual_recursion_contexts_mutex); diff --git a/src/wine-host/utils.h b/src/wine-host/utils.h index 3bfe4f91..0c5f40d7 100644 --- a/src/wine-host/utils.h +++ b/src/wine-host/utils.h @@ -80,25 +80,25 @@ class Win32Thread { * @param parameter The parameter passed to the entry point function. */ template - Win32Thread(Function&& f, Args&&... args) - : handle( - CreateThread( - nullptr, - 0, - reinterpret_cast( - win32_thread_trampoline), - // `std::function` does not support functions with move - // captures the function has to be copy-constructable. - // Function2's unique_function lets us capture and move our - // arguments to the lambda so we don't end up with dangling - // references. - new fu2::unique_function( - [f = std::move(f), ... args = std::move(args)]() mutable { - f(std::move(args)...); - }), - 0, - nullptr), - CloseHandle) {} + Win32Thread(Function&& fn, Args&&... args) + : handle(CreateThread( + nullptr, + 0, + reinterpret_cast( + win32_thread_trampoline), + // `std::function` does not support functions with move + // captures the function has to be copy-constructable. + // Function2's unique_function lets us capture and move our + // arguments to the lambda so we don't end up with dangling + // references. + new fu2::unique_function( + [f = std::forward(fn), + ... args = std::forward(args)]() mutable { + f(std::forward(args)...); + }), + 0, + nullptr), + CloseHandle) {} /** * Join (or wait on, since this is WIn32) the thread on shutdown, just like @@ -254,8 +254,8 @@ class MainContext { * soon as possible, and thus we also won't return a future. */ template - void schedule_task(F fn) { - boost::asio::post(context, std::move(fn)); + void schedule_task(F&& fn) { + boost::asio::post(context, std::forward(fn)); } /**