mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2024-11-12 21:42:51 +01:00
another mutex test
This commit is contained in:
parent
beb18972ea
commit
e613087e97
@ -1,26 +1,8 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
class TestClass {
|
std::recursive_mutex mtx;
|
||||||
public:
|
|
||||||
TestClass() {
|
|
||||||
std::lock_guard<std::recursive_mutex> lck(mtx);
|
|
||||||
value = 42;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getValue() {
|
|
||||||
std::lock_guard<std::recursive_mutex> lck(mtx);
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::recursive_mutex mtx;
|
|
||||||
int value = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
TestClass test;
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
printf("Value: %d\n", test.getValue());
|
std::lock_guard<std::recursive_mutex> lck(mtx);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user