tests/semaphore_unit_test.cc
TEST_F(SemaphoreUnitTest, InitCountAsOneAndOneWaitAndOneNotify) {
  Semaphore semaphore;
  for (int i = 0; i < 100; i++) {
    auto producer_thread(std::thread([&semaphore] () { semaphore.Notify(); }));
    auto consumer_thread(std::thread([&semaphore] () { semaphore.Wait(); }));
    // We expect both threads to complete so join should return successfully
    producer_thread.join();
    consumer_thread.join();
  }
}
// A rather simple multi-threaded case that one thread runs as producer which
// notifies and the other runs as a consumer which wait on the semaphore
// Repeat this exercise for 100 times
A rather simple multi-threaded case that one thread runs as producer which
notifies and the other runs as a consumer which wait on the semaphore
Repeat this exercise for 100 times
A rather simple multi - threaded case that one thread runs as producer which notifies and the other runs as a consumer which wait on the semaphore Repeat this exercise for 100 times
TEST_F(SemaphoreUnitTest, InitCountAsOneAndOneWaitAndOneNotify) {
  Semaphore semaphore;
  for (int i = 0; i < 100; i++) {
    auto producer_thread(std::thread([&semaphore] () { semaphore.Notify(); }));
    auto consumer_thread(std::thread([&semaphore] () { semaphore.Wait(); }));
    producer_thread.join();
    consumer_thread.join();
  }
}
TEST_F ( SemaphoreUnitTest , InitCountAsOneAndOneWaitAndOneNotify ) { Semaphore semaphore ; for ( int i = 0 ; i < 100 ; i ++ ) { auto producer_thread ( std :: thread ( [ & semaphore ] ( ) { semaphore . Notify ( ) ; } ) ) ; auto consumer_thread ( std :: thread ( [ & semaphore ] ( ) { semaphore . Wait ( ) ; } ) ) ; producer_thread . join ( ) ; consumer_thread . join ( ) ; } }
A rather simple multi-threaded case that one thread runs as producer which
notifies and the other runs as a consumer which wait on the semaphore
Repeat this exercise for 100 times
A rather simple multi - threaded case that one thread runs as producer which notifies and the other runs as a consumer which wait on the semaphore Repeat this exercise for 100 times
// We expect both threads to complete so join should return successfully