lestrrat/peco — pull request #49 by lestrrat (2014-06-13 09:13:42+00:00)
Title: Fix synchronization

Because previously everything has been written using non-buffered
channels, the request to refresh the screen would always block.
This resulted in the main thread always waiting to write to
ctx.drawCh until viewer.Loop() registered itself to the waitgroup
via wg.Add(), therefore making the successive wg.Wait() actually wait.

When (this change does not do this) we do use buffered channels,
this guarantee breaks, and the main thread goes immediately to
wg.Wait() before viewer.Loop() has the chance to register
itself to the wait group

This change explicitly forces the main thread to call wg.Add()
to prevent this from happening