In /src/Step_1/ directory run make
. Executable will build as Lock.out. To run executable, run ./Lock.out
.
The test code passed. It performed the same when std::lock_guard
was referenced, and when chal::LockGuard
was referenced. It produced this output, which matched expectations:
armaan@ubuntuVM:Step_1$ ./Lock.out
thread #7
thread #8
thread #9
thread #6
thread #10
thread #5
thread #4
thread #3
thread #2
thread #1
- Pass: The test code performs the same with my namespace and class,
chal::LockGuard
, as it would withstd::lock_guard
. - Fail: Any other result.
Details about my research into lock_guard, mutex, and testing are available here: Reference in Appendix
As this is a first step in a larger project, I intended to replicate already-working code. To that end, I copied std::lock_guard
into a new header file, fixed references to an STD object that was out of namespace, and encapsulated it with my own namespace. To test, I took generic multithread example code that uses std::lock_guard and modified it to use my namespace and class. See Reference in Appendix for details.
Reimplement c++11 lock_guard (NOT use std::lock_guard). Use namespace to allow you to call your class impl "lock_guard" and not conflict with std::lock_guard
LockGuard.h // header file only impl
Initially had trouble parsing requirements. See Reference in Appendix for details.
Performed all coding in a virtual machine running Ubuntu 17.10, 64-bit. To test build environment, created hello world function, and built with makefile. Build successful.
Needed to refamiliarize myself with C++ after spending large amount of time with C and Python. See Reference in Appendix for details.