C++11 library providing functionality common to all adapters.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

37 lines
709 B

// This file is under GNU General Public License 3.0
// see LICENSE.txt
#include <iostream>
#include <thread>
#include "../src/std_utils.hh"
#include "../src/Semaphore.hh"
using namespace std;
using namespace pEp;
int main()
{
Semaphore semaphore;
thread thread1([&]() {
cout << "1: before stop\n";
semaphore.stop();
cout << "1: now on stop\n";
semaphore.try_wait();
cout << "1: and on go again\n";
semaphore.try_wait();
cout << "1: keep going\n";
});
Utils::sleep_millis(1000);
thread thread2([&]() {
cout << "2: setting go\n";
semaphore.go();
});
thread1.join();
thread2.join();
return 0;
}