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