From 936e13ba9225e271911bf097e9f918c80f1d361d Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sun, 2 Apr 2017 15:41:52 +0200 Subject: Add report channel --- philo.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'philo.go') diff --git a/philo.go b/philo.go index 7007a7a..f14c095 100644 --- a/philo.go +++ b/philo.go @@ -17,6 +17,7 @@ type Philo struct { Rounds int MaxDelay time.Duration TimeOut time.Duration + Report chan string } func (p Philo) Delay() { @@ -25,7 +26,7 @@ func (p Philo) Delay() { } func (p Philo) Print(s string) { - fmt.Printf("%10s %s\n", p.Name, s) + p.Report <- fmt.Sprintf("%10s %s", p.Name, s) } func (p Philo) Arrive() stateFn { -- cgit v1.2.3