getChannelPollingLock returns or creates a mutex for the given channel ID
(channelId int)
| 493 | |
| 494 | // getChannelPollingLock returns or creates a mutex for the given channel ID |
| 495 | func getChannelPollingLock(channelId int) *sync.Mutex { |
| 496 | if lock, exists := channelPollingLocks.Load(channelId); exists { |
| 497 | return lock.(*sync.Mutex) |
| 498 | } |
| 499 | // Create new lock for this channel |
| 500 | newLock := &sync.Mutex{} |
| 501 | actual, _ := channelPollingLocks.LoadOrStore(channelId, newLock) |
| 502 | return actual.(*sync.Mutex) |
| 503 | } |
| 504 | |
| 505 | // CleanupChannelPollingLocks removes locks for channels that no longer exist |
| 506 | // This is optional and can be called periodically to prevent memory leaks |