diff options
| author | Brandon C. Irizarry <brandon.irizarry@gmail.com> | 2026-04-23 17:25:25 -0400 |
|---|---|---|
| committer | Brandon C. Irizarry <brandon.irizarry@gmail.com> | 2026-04-23 17:25:25 -0400 |
| commit | 0b945b58ef7ba7d153c25fb86e9b4c5a09003ef0 (patch) | |
| tree | 0e451e93f1d66d652e01d606d464bdd3fba6165c | |
| parent | 431bafa41ae1a4b97b04a43fc491080497229340 (diff) | |
style: rename guild to party
| -rw-r--r-- | main.go | 18 |
1 files changed, 10 insertions, 8 deletions
@@ -44,12 +44,12 @@ func game(numPlayers, faces int) { // player took to hit the winning number. finishedPlayers := make(chan Player) - var guild sync.WaitGroup + var party sync.WaitGroup for i := range numPlayers { id := i + 1 // Spawn a player. - guild.Go(func() { + party.Go(func() { var score int // Start rolling the dice! @@ -69,9 +69,11 @@ func game(numPlayers, faces int) { }) } - // Launch a non-blocking daemon to wait for the guild to - // finish, so that we can close the finishedPlayers channel. - go stopGame(&guild, finishedPlayers) + // Launch a daemon to wait for the party to finish, so that we + // can close the finishedPlayers channel. This has to be + // non-blocking, since the range loop below is synchronized + // with the party members. + go stopGame(&party, finishedPlayers) minPlayer := Player{score: math.MaxInt} @@ -91,9 +93,9 @@ func throwDie(faces int) int { return rand.Intn(faces) + 1 } -// stopGame waits for the members of the guild to finish, and then +// stopGame waits for the members of the party to finish, and then // closes source for use. It functions as a "termination task." -func stopGame(guild *sync.WaitGroup, source chan Player) { - guild.Wait() +func stopGame(party *sync.WaitGroup, source chan Player) { + party.Wait() close(source) } |
