|
C++ Concurrency Sandbox
|
Demonstration of Thread-Safe Data Access using Readers-Writers Lock. More...
#include <iostream>#include <chrono>#include <thread>#include <shared_mutex>#include <vector>#include <mutex>Go to the source code of this file.
Classes | |
| class | SharedMetaData |
| Manages a shared resource with high-concurrency read access. More... | |
Functions | |
| int | main (void) |
| Main execution logic. | |
Variables | |
| std::mutex | log_mtx |
| Global mutex to prevent console output interleaving. | |
Demonstration of Thread-Safe Data Access using Readers-Writers Lock.
Definition in file ReaderWriterLock.cpp.
| int main | ( | void | ) |
Main execution logic.
Definition at line 95 of file ReaderWriterLock.cpp.
References SharedMetaData::read_data(), and SharedMetaData::write_data().
| std::mutex log_mtx |
Global mutex to prevent console output interleaving.
** Standard output (std::cout) is not inherently thread-safe for atomic operations. This mutex ensures that logs from different threads do not garble each other.
Definition at line 19 of file ReaderWriterLock.cpp.
Referenced by SharedMetaData::read_data(), and SharedMetaData::write_data().