Switch sync.Mutex to sync.RWMutex in publisher for improved concurrent read performance.
This commit is contained in:
@@ -56,7 +56,7 @@ func (w *W) Type() (typeName string) { return Type }
|
|||||||
type P struct {
|
type P struct {
|
||||||
c context.Context
|
c context.Context
|
||||||
// Mx is the mutex for the Map.
|
// Mx is the mutex for the Map.
|
||||||
Mx sync.Mutex
|
Mx sync.RWMutex
|
||||||
// Map is the map of subscribers and subscriptions from the websocket api.
|
// Map is the map of subscribers and subscriptions from the websocket api.
|
||||||
Map
|
Map
|
||||||
}
|
}
|
||||||
@@ -150,8 +150,8 @@ func (p *P) Receive(msg typer.T) {
|
|||||||
// for unauthenticated users when events are privileged.
|
// for unauthenticated users when events are privileged.
|
||||||
func (p *P) Deliver(ev *event.E) {
|
func (p *P) Deliver(ev *event.E) {
|
||||||
var err error
|
var err error
|
||||||
p.Mx.Lock()
|
p.Mx.RLock()
|
||||||
defer p.Mx.Unlock()
|
defer p.Mx.RUnlock()
|
||||||
log.D.C(
|
log.D.C(
|
||||||
func() string {
|
func() string {
|
||||||
return fmt.Sprintf(
|
return fmt.Sprintf(
|
||||||
|
|||||||
Reference in New Issue
Block a user