29 lines
736 B
C++
29 lines
736 B
C++
#include "pip.h"
|
|
|
|
|
|
int main(int argc, char * argv[]) {
|
|
PIThreadNotifier n;
|
|
int cnt1 = 0;
|
|
int cnt2 = 0;
|
|
int cnt3 = 0;
|
|
PIThread t1([&n, &cnt1](){n.wait(); cnt1++; piMSleep(1);}, true);
|
|
PIThread t2([&n, &cnt2](){n.wait(); cnt2++; piMSleep(2);}, true);
|
|
piCout << "created";
|
|
piMSleep(10);
|
|
piCout << "unlock" << cnt1 << cnt2 << cnt3;
|
|
n.notifyOnce(); cnt3++;
|
|
piMSleep(10);
|
|
piCout << "unlock" << cnt1 << cnt2 << cnt3;
|
|
n.notifyOnce(); cnt3++;
|
|
piMSleep(10);
|
|
piCout << "run" << cnt1 << cnt2 << cnt3;
|
|
PIThread t3([&n, &cnt3](){n.notifyOnce(); cnt3++; piMSleep(1);}, true);
|
|
piMSleep(20);
|
|
t3.stop();
|
|
piMSleep(100);
|
|
piCout << "exit" << cnt1 << cnt2 << cnt3;
|
|
// m.unlock();
|
|
// piMSleep(10);
|
|
return 0;
|
|
}
|