-
-
Notifications
You must be signed in to change notification settings - Fork 581
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
beb1897
commit e613087
Showing
1 changed file
with
2 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |