PIThreadNotifier, rewrite PIObject::deleteLater()

tests for PIThreadNotifier and PIObject::deleteLater()
This commit is contained in:
Andrey
2021-10-29 18:20:48 +03:00
parent 6e5a5a6ade
commit 48c885e12a
9 changed files with 196 additions and 75 deletions

View File

@@ -1,27 +1,5 @@
#include "pip.h"
class PIThreadNotifier {
public:
PIThreadNotifier(): cnt(0) {}
void wait() {
m.lock();
while (cnt == 0) v.wait(m);
cnt--;
m.unlock();
}
void notifyOnce() {
m.lock();
cnt++;
v.notifyAll();
m.unlock();
}
private:
ullong cnt;
PIMutex m;
PIConditionVariable v;
};
int main(int argc, char * argv[]) {
PIThreadNotifier n;