microsoft / winget-cli

WinGet is the Windows Package Manager. This project includes a CLI (Command Line Interface), PowerShell modules, and a COM (Component Object Model) API (Application Programming Interface).
https://learn.microsoft.com/windows/package-manager/
MIT License
23.03k stars 1.43k forks source link

Configuration apply queueing #4590

Closed JohnMcPMS closed 3 months ago

JohnMcPMS commented 3 months ago

Change

Adds a queue table to the configuration database and some code to synchronize the application of configurations.

Every apply in the queue puts a row in the table, with its instance identifier (it should also be in the history) and a named object that it will keep alive as long as it is in the queue. This allows for other queued processes to check for dead queue items.

A global named mutex must be held in order to apply, or even check if one is at the front of the queue. If not at the front of the queue, the waiting operation will release the mutex and wait for N * 100ms where N is their perceived position in the queue. This should prevent repeated contention on the global mutex as the queued items sort themselves via the wait.

Validation

Manual use with a configuration that allowed control of completion. Added automated tests. Plan to refactor out some of the internals in the future so that they can be directly unit tested.

Microsoft Reviewers: Open in CodeFlow