Yoooi0 / MultiFunPlayer

flexible application to synchronize various devices with media playback
https://yoooi0.github.io/MultiFunPlayer/
MIT License
105 stars 20 forks source link

Add support for async actions #158

Closed Yoooi0 closed 3 months ago

Yoooi0 commented 4 months ago

Mainly for media source/output target client refresh or connection actions.

How to prevent tasks constantly getting created on repeating shortcuts? Somehow only allow async actions on specific shortcut types? (press/release/click etc.) How to prevent the same async action from getting called from multiple shortcuts? Wait to finish/discard? Or should the async action implementation handle concurrent calls?

Current invoke method executes one by one:

* for each input processor
  * generate gestures
  * for each gesture
    * for each shortcut
      * update shortcut with gesture
        * if shortcut triggers
          * for each assigned action
            * invoke action

So if we just push a new task that invokes assigned actions to a queue and execute one by one then it simulates current behavior.

Probably convert all to ValueTask? How to make it still sync if all actions are sync? Do we have to spawn a new task/thread for each shortcut trigger? Or create one "processing" task that consumes incomming "invoke requests".

Ideally display to user that the shortcut is busy? Could be a solution for repeating shortcuts, busy = no more triggers allowed, ignore incoming gestures. Need a timeout in the queue processor.

Update of #113