mirror of
https://github.com/simon987/task_tracker.git
synced 2025-12-14 23:39:04 +00:00
Fix race condition
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/simon987/task_tracker/config"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type Database struct {
|
||||
@@ -14,12 +15,14 @@ type Database struct {
|
||||
saveTaskStmt *sql.Stmt
|
||||
|
||||
workerCache map[int64]*Worker
|
||||
assignMutex *sync.Mutex
|
||||
}
|
||||
|
||||
func New() *Database {
|
||||
|
||||
d := Database{}
|
||||
d.workerCache = make(map[int64]*Worker)
|
||||
d.assignMutex = &sync.Mutex{}
|
||||
|
||||
d.init()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user