We count up on a sequence number, firing on the event when we've hit our expected amount, otherwise we wait on the event. This will ensure that we have all threads outstanding until we hit our expected thread pool size.
| 55 | // expected amount, otherwise we wait on the event. This will ensure that we |
| 56 | // have all threads outstanding until we hit our expected thread pool size. |
| 57 | class VerifyPoolRunner : public DelegateSimpleThread::Delegate { |
| 58 | public: |
| 59 | VerifyPoolRunner(AtomicSequenceNumber* seq, |
| 60 | int total, WaitableEvent* event) |
| 61 | : seq_(seq), total_(total), event_(event) { } |
| 62 | |
| 63 | virtual void Run() OVERRIDE { |
| 64 | if (seq_->GetNext() == total_) { |
| 65 | event_->Signal(); |
| 66 | } else { |
| 67 | event_->Wait(); |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | private: |
| 72 | AtomicSequenceNumber* seq_; |
| 73 | int total_; |
| 74 | WaitableEvent* event_; |
| 75 | }; |
| 76 | |
| 77 | } // namespace |
| 78 |