cvmfs/cvmfs — pull request #320 by reneme (2013-12-13 10:38:25+00:00)
Title: Refactor Cumbersome Synchronisation in AsyncReader

As a result of our exhaustive discussion, I decided to refactor the synchronisation method in `AsyncReader`, which shows the same communication pattern as we discussed yesterday by email.
It is basically a mixture of both approaches. Communication is done through a `tbb::concurrent_bounded_queue` whereas the flow of work items is controlled using a semaphore-like `BlockingCounter`. A `BlockingCounter` basically wraps the synchronisation magic implemented twice in the `AsyncReader` before. You can increment a `BlockingCounter` as long as it reaches a maximal value, which causes the incrementing thread to block until another thread decrements the `BlockingCounter` again. Additionally to this semaphore-like behaviour it is also possible to call `BlockingCounter::WaitForZero()`, which allows a thread to block until the `BlockingCounter` reaches zero again.
`WaitForZero()` is used to wait until all work items are processed in a convenient way.

*Unit test cases included*