You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

31 lines
566 B

package store
import (
"errors"
"fmt"
"sync"
"sync/atomic"
"texas-poker-bk/internal/game"
)
var (
TableNo *atomic.Int32
LobbyTables map[int32]*game.Table
LobbyLock *sync.Mutex
)
func init() {
TableNo = &atomic.Int32{}
LobbyTables = make(map[int32]*game.Table, 16)
LobbyLock = &sync.Mutex{}
}
func SaveNewTable(table *game.Table) error {
LobbyLock.Lock()
defer LobbyLock.Unlock()
if LobbyTables[table.TableNo] != nil {
return errors.New(fmt.Sprintf("table no %d exists!", table.TableNo))
}
LobbyTables[table.TableNo] = table
return nil
}