Skip to content

Commit

Permalink
sort out concurrency again
Browse files Browse the repository at this point in the history
  • Loading branch information
ftl committed May 30, 2024
1 parent 3be32da commit f864149
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
15 changes: 8 additions & 7 deletions core/logbook/qsolist.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ func (l *QSOList) Fill(qsos []core.QSO) {

l.dataLock.Unlock()

l.scorer.Unmute()
l.emitQSOsCleared()
for _, qso := range allQSOs {
l.emitQSOAdded(qso)
Expand All @@ -155,12 +156,14 @@ func (l *QSOList) Put(qso core.QSO) {

emitNotifications := l.put(qso)

l.refreshScore()
allQSOs := l.all()
l.dataLock.Unlock()

emitNotifications()
emitNotifications(allQSOs)
}

func (l *QSOList) put(qso core.QSO) func() {
func (l *QSOList) put(qso core.QSO) func([]core.QSO) {
if len(l.list) == 0 {
return l.append(qso)
}
Expand All @@ -176,10 +179,8 @@ func (l *QSOList) put(qso core.QSO) func() {
} else {
l.update(index, qso)
}
l.refreshScore()
qsos := l.all()

return func() {
return func(qsos []core.QSO) {
l.scorer.Unmute()
l.emitQSOsCleared()
for _, qso := range qsos {
Expand Down Expand Up @@ -213,7 +214,7 @@ func findIndex(list []core.QSO, number core.QSONumber) (int, bool) {
return low, true
}

func (l *QSOList) append(qso core.QSO) func() {
func (l *QSOList) append(qso core.QSO) func([]core.QSO) {
score := l.scorer.AddMuted(qso)
qso.Points = score.Points
qso.Multis = score.Multis
Expand All @@ -225,7 +226,7 @@ func (l *QSOList) append(qso core.QSO) func() {

l.list = append(l.list, qso)

return func() {
return func([]core.QSO) {
l.scorer.Unmute()
l.emitQSOAdded(qso)
}
Expand Down
2 changes: 0 additions & 2 deletions core/score/score.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,6 @@ func (c *Counter) Clear() {
c.resetCounter() // CONVAL WRITE LOCK

c.invalid = (c.contestSetup.MyCountry == "")

c.emitScoreUpdated(c.readScore) // READ
}

func (c *Counter) AddMuted(qso core.QSO) core.QSOScore {
Expand Down

0 comments on commit f864149

Please sign in to comment.