| 7 | using namespace std::literals; |
| 8 | |
| 9 | class Database |
| 10 | { |
| 11 | public: |
| 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_ }; |
| 20 | std::this_thread::sleep_for(300ms); // Assuming we need 300ms to write. |
| 21 | data_ = d; |
| 22 | } |
| 23 | private: |
| 24 | std::shared_mutex mutex_; |
| 25 | int data_ = 0; |
| 26 | }; |
| 27 | |
| 28 | int main() |
| 29 | { |
nothing calls this directly
no outgoing calls
no test coverage detected