summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrandon C. Irizarry <brandon.irizarry@gmail.com>2026-04-23 17:25:25 -0400
committerBrandon C. Irizarry <brandon.irizarry@gmail.com>2026-04-23 17:25:25 -0400
commit0b945b58ef7ba7d153c25fb86e9b4c5a09003ef0 (patch)
tree0e451e93f1d66d652e01d606d464bdd3fba6165c
parent431bafa41ae1a4b97b04a43fc491080497229340 (diff)
style: rename guild to party
-rw-r--r--main.go18
1 files changed, 10 insertions, 8 deletions
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)
}