remove migrations
This commit is contained in:
26
bot/mutex.go
Normal file
26
bot/mutex.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package bot
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"maunium.net/go/mautrix/id"
|
||||
)
|
||||
|
||||
func (b *Bot) lock(roomID id.RoomID) {
|
||||
_, ok := b.mu[roomID]
|
||||
if !ok {
|
||||
b.mu[roomID] = &sync.Mutex{}
|
||||
}
|
||||
|
||||
b.mu[roomID].Lock()
|
||||
}
|
||||
|
||||
func (b *Bot) unlock(roomID id.RoomID) {
|
||||
_, ok := b.mu[roomID]
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
b.mu[roomID].Unlock()
|
||||
delete(b.mu, roomID)
|
||||
}
|
||||
Reference in New Issue
Block a user