Book Concurrency with Modern C++ ⬆
![]() |
Directory concurrency-examples\ contains C++ code examples from the book Concurrency with Modern C++ by Rainer Grimm (Leanpub, 2023).It also includes several build scripts (batch files, bash scripts, Make scripts) for running the example on a Windows machine. |
This example has the following directory structure :
> tree /a /f . | findstr /v /b [A-Z] | build.bat | build.sh | CMakeLists.txt | Doxyfile | Makefile \---src \---main \---cpp acquireConsume.cpp
Command build.bat
run
generates and executes the C++ program target\acquireConsume.exe
(with options -bcc
, -clang
, -gcc
, -icx
and -msvc
to specify a compiler).
> build -verbose -gcc run Toolset: GCC/GNU Make, Project: acquireConsume Generate configuration files into directory "build" Generate executable "acquireConsume.exe" Execute "build\acquireConsume.exe" *p2: C++11 data: 2011 atoData: 2014
One may also run command make
run
:
> make clean run "C:/opt/msys64/usr/bin/rm.exe" -rf "build" "C:/opt/msys64/mingw64/bin/g++.exe" --std=c++17 -O2 -Wall -Wno-unused-variable -o build/Release/acquireConsume.exe src/main/cpp/acquireConsume.cpp build/Release/acquireConsume.exe *p2: C++11 data: 2011 atoData: 2014
fetch_mult
Example ▴
This example has the following directory structure :
> tree /a /f . | findstr /v /b [A-Z] | build.bat | CMakeLists.txt | Makefile \---src \---main \---cpp fetch_mult.cpp
Command build.bat
-verbose clean run
(with options -clang
, -gcc
, -icx
and -msvc
) generates and executes the program build\Release\fetch_mult.exe
:
> build -verbose clean run Delete directory "build" Toolset: MSVC/MSBuild, Project: fetch_mult Configuration: Release, Platform: x64 Generate configuration files into directory "build" Generate executable "fetch_mult.exe" Execute "build\Release\fetch_mult.exe" 5 25
Command make
TOOLSET=icx clean run
generates and executes the program build\Release\fetch_mult.exe
:
> make TOOLSET=icx clean run "C:/opt/msys64/usr/bin/rm.exe" -rf "build" "C:/Program Files (x86)/Intel/oneAPI//compiler/latest/windows/bin/icx.exe" -Qstd=c++17 -O2 -Fe"build/Release/fetch_mult.exe" -o build/Release/fetch_mult.exe src/main/cpp/fetch_mult.cpp -link -libpath:"X:/VC/Tools/MSVC/14.36.32532//lib/x64" -libpath:"C:/Program Files (x86)/Windows Kits/10/lib/10.0.22000.0/ucrt/x64" -libpath:"C:/Program Files (x86)/Windows Kits/10/lib/10.0.22000.0/um/x64" -libpath:"C:/Program Files (x86)/Intel/oneAPI//compiler/latest/windows/compiler/lib" -libpath:"C:/Program Files (x86)/Intel/oneAPI//compiler/latest/windows/compiler/lib/intel64" build/Release/fetch_mult.exe 5 25
mutex
Example ▴
This example has the following directory structure :
> tree /a /f . | findstr /v /b [A-Z] | build.bat | build.sh | CMakeLists.txt | Doxyfile | Makefile \---src mutex.cpp
transitivity
Example ▴
This example has the following directory structure :
> tree /a /f . | findstr /v /b [A-Z] | build.bat | CMakeLists.txt | Makefile \---src \---main \---cpp transitivity.cpp
Command build.bat
-verbose clean run
(with options -bcc
, -clang
, -gcc
, -icx
and -msvc
) generates and executes the program build\Release\transitivity.exe
:
> build -verbose clean run Delete directory "build" Toolset: MSVC/MSBuild, Project: transitivity Configuration: Release, Platform: x64 Generate configuration files into directory "build" Generate executable "transitivity.exe" Execute "build\Release\transitivity.exe" 1 2 3