BUG-1455: improve thread safety/performance
There were couple of things wrong with this code: flipping 'starving'
field needlessly, which could end up in needless calls to notify().
Split that field into local state and volatile status indicator.
finished is not volatile, so the checks can actually get removed at
runtime, breaking the shutdown() functionality. Also an explicit ping()
is needed to wake a starving harvester.
Change-Id: I58b46a3f2e593e3873c47c30d2fe0d22d4304e8f
Signed-off-by: Robert Varga <rovarga@cisco.com>
Signed-off-by: Vaclav Demcak <vdemcak@cisco.com>