mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-10-17 00:34:01 -04:00
cards: fix regression that created borders matugen: run on a low priority worker and seeds dms-colors before other templates
36 lines
571 B
Go
36 lines
571 B
Go
package dgop
|
|
|
|
import (
|
|
"runtime"
|
|
"sync"
|
|
|
|
"github.com/AvengeMedia/DankMaterialShell/core/internal/lowprio"
|
|
)
|
|
|
|
var (
|
|
startWorker sync.Once
|
|
jobs chan func()
|
|
)
|
|
|
|
func runLowPriority(job func()) {
|
|
startWorker.Do(func() {
|
|
jobs = make(chan func())
|
|
go worker()
|
|
})
|
|
done := make(chan struct{})
|
|
jobs <- func() {
|
|
defer close(done)
|
|
job()
|
|
}
|
|
<-done
|
|
}
|
|
|
|
// Sampling must never preempt a foreground app, so it runs on one OS thread with lowered priority.
|
|
func worker() {
|
|
runtime.LockOSThread()
|
|
lowprio.LowerThreadPriority()
|
|
for job := range jobs {
|
|
job()
|
|
}
|
|
}
|