From 0b945b58ef7ba7d153c25fb86e9b4c5a09003ef0 Mon Sep 17 00:00:00 2001 From: "Brandon C. Irizarry" Date: Thu, 23 Apr 2026 17:25:25 -0400 Subject: style: rename guild to party --- main.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index ee0d77e..2f524c1 100644 --- a/main.go +++ b/main.go @@ -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) } -- cgit v1.2.3