mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-05 21:15:38 -05:00
core: more syncmap conversions
This commit is contained in:
@@ -33,10 +33,10 @@ package ext_workspace
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"sync"
|
||||
"unsafe"
|
||||
|
||||
"github.com/AvengeMedia/DankMaterialShell/core/pkg/go-wayland/wayland/client"
|
||||
"github.com/AvengeMedia/DankMaterialShell/core/pkg/syncmap"
|
||||
)
|
||||
|
||||
// registerServerProxy registers a proxy with a server-assigned ID.
|
||||
@@ -63,7 +63,7 @@ func registerServerProxy(ctx *client.Context, proxy client.Proxy, serverID uint3
|
||||
}
|
||||
|
||||
objectsMapPtr := unsafe.Pointer(objectsField.UnsafeAddr())
|
||||
objectsMap := (*sync.Map)(objectsMapPtr)
|
||||
objectsMap := (*syncmap.Map[uint32, client.Proxy])(objectsMapPtr)
|
||||
objectsMap.Store(serverID, proxy)
|
||||
}
|
||||
|
||||
|
||||
@@ -31,10 +31,10 @@ package wlr_output_management
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"sync"
|
||||
"unsafe"
|
||||
|
||||
"github.com/AvengeMedia/DankMaterialShell/core/pkg/go-wayland/wayland/client"
|
||||
"github.com/AvengeMedia/DankMaterialShell/core/pkg/syncmap"
|
||||
)
|
||||
|
||||
func registerServerProxy(ctx *client.Context, proxy client.Proxy, serverID uint32) {
|
||||
@@ -49,7 +49,7 @@ func registerServerProxy(ctx *client.Context, proxy client.Proxy, serverID uint3
|
||||
return
|
||||
}
|
||||
objectsMapPtr := unsafe.Pointer(objectsField.UnsafeAddr())
|
||||
objectsMap := (*sync.Map)(objectsMapPtr)
|
||||
objectsMap := (*syncmap.Map[uint32, client.Proxy])(objectsMapPtr)
|
||||
objectsMap.Store(serverID, proxy)
|
||||
}
|
||||
|
||||
|
||||
@@ -6,11 +6,13 @@ import (
|
||||
"net"
|
||||
"os"
|
||||
"sync"
|
||||
|
||||
"github.com/AvengeMedia/DankMaterialShell/core/pkg/syncmap"
|
||||
)
|
||||
|
||||
type Context struct {
|
||||
conn *net.UnixConn
|
||||
objects sync.Map // map[uint32]Proxy - thread-safe concurrent map
|
||||
objects syncmap.Map[uint32, Proxy] // map[uint32]Proxy - thread-safe concurrent map
|
||||
currentID uint32
|
||||
idMu sync.Mutex // protects currentID increment
|
||||
}
|
||||
@@ -32,7 +34,7 @@ func (ctx *Context) Unregister(p Proxy) {
|
||||
|
||||
func (ctx *Context) GetProxy(id uint32) Proxy {
|
||||
if val, ok := ctx.objects.Load(id); ok {
|
||||
return val.(Proxy)
|
||||
return val
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -68,12 +70,12 @@ func (ctx *Context) GetDispatch() func() error {
|
||||
}
|
||||
|
||||
return func() error {
|
||||
val, ok := ctx.objects.Load(senderID)
|
||||
proxy, ok := ctx.objects.Load(senderID)
|
||||
if !ok {
|
||||
return fmt.Errorf("%w (senderID=%d)", ErrDispatchSenderNotFound, senderID)
|
||||
}
|
||||
|
||||
sender, ok := val.(Dispatcher)
|
||||
sender, ok := proxy.(Dispatcher)
|
||||
if !ok {
|
||||
return fmt.Errorf("%w (senderID=%d)", ErrDispatchSenderUnsupported, senderID)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user