mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-06-23 20:37:27 +02:00
💥 Redo all higher order template functions
This does what we did for a few functions in the last few commits for every function. We now use either the `std::invocable` concept or our own `invocable_returning` concept wherever possible to make sure we pass function types to these template functions, since constraint errors are a lot more readable than template deduction errors. And instead of having to specify the return type as a template argument, we now just use `std::invoke_result_t<F>` instead. The VST3 message handling functions are still using the good old `typename F` since those are overloaded polymorphic functions. This was also a good moment to modify `AdHocSocketHandler::send()` to allow functions returning void (this got rid of an old fixme where we had to return some dummy value from a function instead of just not returning anything).
This commit is contained in:
@@ -294,12 +294,9 @@ class Vst3Bridge : public HostBridge {
|
||||
* run on the UI thread through `main_context` as usual.
|
||||
*
|
||||
* @see Vst3Bridge::send_mutually_recursive_message
|
||||
*
|
||||
* TODO: Refactor these two functions, `run_gui_task()`, and
|
||||
* `main_context.run_in_context` to use `std::invocation_result_t`
|
||||
*/
|
||||
template <typename T, typename F>
|
||||
T do_mutual_recursion_on_gui_thread(F&& fn) {
|
||||
template <std::invocable F>
|
||||
std::invoke_result_t<F> do_mutual_recursion_on_gui_thread(F&& fn) {
|
||||
// If the above function is currently being called from some thread,
|
||||
// then we'll call `fn` from that same thread. Otherwise we'll just
|
||||
// submit it to the main IO context.
|
||||
@@ -317,8 +314,8 @@ class Vst3Bridge : public HostBridge {
|
||||
*
|
||||
* @see Vst3Bridge::do_mutual_recursion_on_gui_thread
|
||||
*/
|
||||
template <typename T, typename F>
|
||||
T do_mutual_recursion_on_off_thread(F&& fn) {
|
||||
template <std::invocable F>
|
||||
std::invoke_result_t<F> do_mutual_recursion_on_off_thread(F&& fn) {
|
||||
return mutual_recursion.handle(std::forward<F>(fn));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user