Add possibility to wait several times on a semaphore

This commit is contained in:
Johan Wikman
2017-04-24 15:38:08 +03:00
parent 19cf8c489e
commit 1eb409a666
3 changed files with 155 additions and 12 deletions

View File

@ -65,6 +65,14 @@ void test_simple()
ss_dassert(rv);
cout << "Waited" << endl;
sem2.post();
sem2.post();
sem2.post();
cout << "Waiting 3 times for semaphore with a count of 3." << endl;
rv = sem2.wait_n(3);
cout << "Waited" << endl;
Semaphore sem3;
time_t started;
@ -118,10 +126,7 @@ void test_threads()
cout << "Waiting for threads." << endl;
for (int i = 0; i < n_threads; ++i)
{
sem.wait();
}
sem.wait_n(n_threads);
cout << "Joining threads." << endl;