another mutex test

This commit is contained in:
AlexandreRouma 2024-06-26 12:51:13 +02:00
parent beb18972ea
commit e613087e97

View File

@ -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;
}