mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 22:31:06 +08:00
22 lines
398 B
Go
22 lines
398 B
Go
package application
|
|
|
|
import (
|
|
"sync"
|
|
)
|
|
|
|
var mainThreadFunctionStore = make(map[uint]func())
|
|
var mainThreadFunctionStoreLock sync.RWMutex
|
|
|
|
func generateFunctionStoreID() uint {
|
|
startID := 0
|
|
for {
|
|
if _, ok := mainThreadFunctionStore[uint(startID)]; !ok {
|
|
return uint(startID)
|
|
}
|
|
startID++
|
|
if startID == 0 {
|
|
Fatal("Too many functions have been dispatched to the main thread")
|
|
}
|
|
}
|
|
}
|