PIThreadNotifier, rewrite PIObject::deleteLater()
tests for PIThreadNotifier and PIObject::deleteLater()
This commit is contained in:
22
main.cpp
22
main.cpp
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user