VT_Player/third_party/gotk3/internal/callback/callback.go
Stu d4efa91ce1 Add vendored gotk3 GTK3 bindings for Go
Vendor gotk3 library to ensure consistent GTK3 bindings across
environments and simplify dependency management.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-15 05:40:43 -05:00

38 lines
509 B
Go

package callback
import (
"sync"
"github.com/gotk3/gotk3/internal/slab"
)
var (
mutex sync.RWMutex
registry slab.Slab
)
func Assign(callback interface{}) uintptr {
mutex.Lock()
defer mutex.Unlock()
return registry.Put(callback)
}
func Get(ptr uintptr) interface{} {
mutex.RLock()
defer mutex.RUnlock()
return registry.Get(ptr)
}
func Delete(ptr uintptr) {
GetAndDelete(ptr)
}
func GetAndDelete(ptr uintptr) interface{} {
mutex.Lock()
defer mutex.Unlock()
return registry.Pop(ptr)
}