MCPcopy Create free account
hub / github.com/Extra-Creativity/Modern-Cpp-Basics / Read

Method Read

13-Multithreading/code/shared_mutex.cpp:12–16  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10{
11public:
12 int Read() {
13 std::shared_lock sharedLock{ mutex_ };
14 std::this_thread::sleep_for(100ms); // Assuming we need 100ms to read
15 return data_;
16 }
17
18 void Write(int d) {
19 std::lock_guard exclusiveLock{ mutex_ };

Callers 1

mainFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected