Commit 16de8aef authored by Boris Mühmer's avatar Boris Mühmer
Browse files

stricter channel usage, and some minor corrections

parent b9d92cf4
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -54,8 +54,8 @@ func TestTicketsComplex(t *testing.T) {
		ID, Count int
	}

	maxTickets := 200
	numWorkers := runtime.NumCPU()
	maxTickets := 500
	numWorkers := runtime.NumCPU() * 2
	numBuffered := 50 // 0 for an unbuffered channel

	t.Logf("number of tickets: %d", maxTickets)
@@ -81,9 +81,9 @@ func TestTicketsComplex(t *testing.T) {
	}(maxTickets)

	// dispatch work to distinct goroutines
	workerResultStreamArray := make([]chan WorkerResult, numWorkers)
	workerResultStreamArray := make([]<-chan WorkerResult, numWorkers)
	for workerIndex := 0; workerIndex < numWorkers; workerIndex++ {
		workerResultStreamArray[workerIndex] = func(id int, ticketStream chan *Ticket) chan WorkerResult {
		workerResultStreamArray[workerIndex] = func(id int, ticketStream <-chan *Ticket) <-chan WorkerResult {
			workerResultStream := make(chan WorkerResult)
			count := 0

@@ -123,7 +123,7 @@ func TestTicketsComplex(t *testing.T) {
		t.Logf("worker %d processed %d", i.ID, i.Count)
		processedTickets += i.Count
	}
	t.Logf("processed tickets: %d - process duration: %s", processedTickets, totalProcessDuration.String())
	t.Logf("processed tickets: %d - total process duration: %s", processedTickets, totalProcessDuration.String())
	if maxTickets != processedTickets {
		t.Errorf("the count of processed tickets is %d, expected %d", processedTickets, maxTickets)
	}