Skip to content

Commit b81b7e7

Browse files
Updated comments.
1 parent 0c9e0d2 commit b81b7e7

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎chapter7/patterns/timer/timer.go‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright Information.
2+
3+
// This example is provided with help by Gabriel Aszalos.
4+
15
// This sample program demonstrates how to use a channel to
26
// monitor the amount of time the program is running and terminate
37
// the program if it runs too long.
@@ -12,8 +16,6 @@ import (
1216
"time"
1317
)
1418

15-
// LET'S TALK ABOUT USING ENV VARIABLES INSTEAD
16-
1719
// flagSec is a command line flag to set the timeout in seconds.
1820
var flagSec = flag.Int("ttl", 3, "timeout in seconds")
1921

@@ -78,11 +80,15 @@ func (t *timer) Start() {
7880
// run executes each registered task.
7981
func (t *timer) run(tasks ...func(int)) error {
8082
for id, task := range tasks {
83+
// Check for an interrupt signal for the OS.
8184
if t.gotInterrupt() {
8285
return errors.New("Early Shutdown")
8386
}
87+
88+
// Execute the registered task.
8489
task(id)
8590
}
91+
8692
return nil
8793
}
8894

0 commit comments

Comments
 (0)