├── .gitignore ├── .gitmodules ├── README.md ├── cpp16 ├── lecture-code │ ├── lec11 │ │ ├── main.cpp │ │ └── thread_pool.h │ ├── lec12 │ │ ├── 01.cpp │ │ ├── 02.cpp │ │ ├── 03.cpp │ │ ├── 04.cpp │ │ ├── 05.cpp │ │ └── stack_example_from_rl.cpp │ ├── lec15 │ │ └── 01.cpp │ ├── lec2 │ │ ├── IntVector.h │ │ ├── lec2.sln │ │ ├── lec2_move_semantic.vcxproj │ │ ├── lec2_move_semantic.vcxproj.filters │ │ └── main.cpp │ ├── lec4 │ │ ├── any.h │ │ ├── any.sln │ │ ├── any.vcxproj │ │ └── lec4.cpp │ ├── lec6 │ │ ├── DebugAllocator.h │ │ ├── TestSpeed.h │ │ └── custom_allocator.cpp │ ├── lec7 │ │ ├── gc.sln │ │ ├── gc.vcxproj.filters │ │ └── lec7.cpp │ ├── lec8 │ │ ├── 01.cpp │ │ ├── 02.cpp │ │ ├── 03.cpp │ │ ├── 04.cpp │ │ ├── 05.cpp │ │ ├── 06.cpp │ │ ├── 07.cpp │ │ ├── 08.cpp │ │ ├── 09.cpp │ │ ├── 10.cpp │ │ ├── 11.cpp │ │ ├── 12.cpp │ │ ├── 13.cpp │ │ └── 14.cpp │ └── lec9 │ │ ├── 00.cpp │ │ ├── 01.cpp │ │ ├── 02.cpp │ │ ├── 03.cpp │ │ ├── 03a.cpp │ │ ├── 04.cpp │ │ ├── 05.cpp │ │ ├── 06.cpp │ │ ├── 07.cpp │ │ ├── 08.cpp │ │ └── 09.cpp └── lecture-slides │ ├── lec10_atomic.pdf │ ├── lec11_threadPool.pdf │ ├── lec12_lockFree.pdf │ ├── lec14_network.pdf │ ├── lec15_sfinae_pimpl.pdf │ ├── lec1_introCpp11.pdf │ ├── lec2_rvalues.pdf │ ├── lec4_introCpp17.pdf │ ├── lec5_smartPointers.pdf │ ├── lec6_memory_managment.pdf │ ├── lec7_garbage_collection.pdf │ ├── lec8_introMultithreading.pdf │ └── lec9_async.pdf ├── cpp17 └── lectures │ ├── 01_introduction │ └── introduction.pdf │ ├── 02_move_semantics │ ├── move_semantics.pdf │ └── sources │ │ ├── 01.cpp │ │ ├── 02.cpp │ │ ├── 03.cpp │ │ ├── 04.cpp │ │ └── 05.cpp │ ├── 03_smart_pointers │ ├── smart_pointers.pdf │ └── sources │ │ ├── 01.cpp │ │ ├── 02.cpp │ │ ├── 03.cpp │ │ └── 04.cpp │ ├── 04_multithreading │ ├── multithreading.pdf │ └── sources │ │ ├── 01.cpp │ │ ├── 02.cpp │ │ ├── 03.cpp │ │ ├── 03a.cpp │ │ ├── 04.cpp │ │ ├── 05.cpp │ │ ├── 06.cpp │ │ ├── 07.cpp │ │ ├── 08.cpp │ │ ├── 08a.cpp │ │ ├── 09.cpp │ │ └── 10.cpp │ ├── 05_synchronization │ ├── sources │ │ ├── 01.cpp │ │ ├── 02.cpp │ │ ├── 03.cpp │ │ ├── 04.cpp │ │ └── 05.cpp │ └── synchronization.pdf │ ├── 05_thread_pool │ ├── sources │ │ ├── main.cpp │ │ └── thread_pool.h │ └── thread_pool.pdf │ ├── 06_networks │ ├── networks.pdf │ └── sources │ │ ├── client.cpp │ │ ├── server.cpp │ │ ├── server_asio.cpp │ │ └── server_refactoring.cpp │ └── 07_memory_management │ └── memory_management.pdf ├── cpp18 └── lectures │ ├── 01_introduction │ └── introduction.pdf │ ├── 02_smart_pointers │ └── smart_pointers.pdf │ ├── 03_move_semantics │ ├── code │ │ └── lec │ │ │ ├── benchmark.cpp │ │ │ ├── by_value.cpp │ │ │ ├── lec.sln │ │ │ └── move_and_forward.cpp │ └── move_semantics.pdf │ ├── 04_multithreads │ ├── multithreading.pdf │ └── sources │ │ ├── 01.cpp │ │ ├── 02.cpp │ │ ├── 03.cpp │ │ ├── 03a.cpp │ │ ├── 04.cpp │ │ ├── 05.cpp │ │ ├── 06.cpp │ │ ├── 07.cpp │ │ ├── 08.cpp │ │ ├── 08a.cpp │ │ ├── 09.cpp │ │ └── 10.cpp │ ├── 05_network │ ├── code │ │ ├── client.cpp │ │ ├── server.cpp │ │ ├── server_asio.cpp │ │ └── server_refactoring.cpp │ └── network.pdf │ └── 06_synchronization │ ├── sources │ ├── lec │ │ ├── 01.cpp │ │ ├── 02.cpp │ │ ├── 03.cpp │ │ ├── 04.cpp │ │ └── 05.cpp │ └── thread_pool │ │ ├── main.cpp │ │ └── thread_pool.h │ ├── synchronization.pdf │ └── thread_pool.pdf ├── cpp19 ├── 02_smart_pointers.pdf ├── 04_multithreads.pdf ├── lec_02 │ └── source │ │ ├── lec_02_source │ │ ├── custom_deleters.cpp │ │ ├── file_storage.cpp │ │ ├── file_storage.h │ │ ├── http_server.cpp │ │ ├── http_server.h │ │ ├── lec_02_source.vcxproj │ │ ├── lec_02_source.vcxproj.user │ │ ├── main.cpp │ │ ├── sql_connection.cpp │ │ ├── sql_connection.h │ │ └── storage.h │ │ └── smart_pointers.sln ├── lec_04 │ ├── lec_04_source │ │ ├── browser_suggest.cpp │ │ ├── http_server.cpp │ │ ├── lec_04_source.vcxproj │ │ └── lec_04_source.vcxproj.user │ └── threads.sln ├── lec_05 │ └── source │ │ ├── .clang-format │ │ ├── .github │ │ └── settings.yml │ │ ├── .gitignore │ │ ├── .gitmodules │ │ ├── .travis.yml │ │ ├── AUTHORS │ │ ├── CMakeLists.txt │ │ ├── CONTRIBUTING.md │ │ ├── Dockerfile │ │ ├── LICENSE │ │ ├── cmake │ │ ├── FindGcov.cmake │ │ ├── FindLcov.cmake │ │ └── Findcodecov.cmake │ │ ├── images │ │ └── .gitkeep │ │ ├── include │ │ └── header.hpp │ │ ├── misc │ │ └── .gitkeep │ │ ├── scripts │ │ ├── checks.sh │ │ ├── coverage.sh │ │ ├── duplication.sh │ │ ├── genenv.sh │ │ └── tests.sh │ │ ├── sources │ │ └── source.cpp │ │ ├── tests │ │ └── test.cpp │ │ └── third-party │ │ └── .gitkeep ├── lec_06 │ └── source │ │ ├── .clang-format │ │ ├── .github │ │ └── settings.yml │ │ ├── .gitignore │ │ ├── .gitmodules │ │ ├── .travis.yml │ │ ├── AUTHORS │ │ ├── CMakeLists.txt │ │ ├── CONTRIBUTING.md │ │ ├── Dockerfile │ │ ├── LICENSE │ │ ├── cmake │ │ ├── FindGcov.cmake │ │ ├── FindLcov.cmake │ │ └── Findcodecov.cmake │ │ ├── images │ │ └── .gitkeep │ │ ├── include │ │ └── header.hpp │ │ ├── misc │ │ └── .gitkeep │ │ ├── scripts │ │ ├── checks.sh │ │ ├── coverage.sh │ │ ├── duplication.sh │ │ ├── genenv.sh │ │ └── tests.sh │ │ ├── sources │ │ └── source.cpp │ │ ├── tests │ │ └── test.cpp │ │ └── third-party │ │ └── .gitkeep ├── lec_07 │ ├── README.md │ ├── async_echo.cpp │ └── lock_free_stack.h └── lec_08 │ └── source │ └── any.h └── docs ├── index.html ├── lec_01 ├── index.html ├── libs │ ├── highlight.js │ │ └── 9.12.0 │ │ │ ├── darcula.css │ │ │ ├── darkula.css │ │ │ ├── highlight.js │ │ │ └── reveal-code-focus-1.0.0-mod.js │ └── reveal.js │ │ ├── 3.8.0 │ │ ├── css │ │ │ ├── print │ │ │ │ └── paper.css │ │ │ ├── reveal.css │ │ │ └── theme │ │ │ │ └── Night.css │ │ ├── js │ │ │ └── reveal.js │ │ ├── lib │ │ │ └── js │ │ │ │ └── head.min.js │ │ └── plugin │ │ │ ├── anything │ │ │ └── anything.js │ │ │ ├── chalkboard │ │ │ ├── chalkboard.js │ │ │ └── img │ │ │ │ ├── blackboard.png │ │ │ │ ├── boardmarker.png │ │ │ │ ├── chalk.png │ │ │ │ └── sponge.png │ │ │ ├── chart │ │ │ ├── Chart.min.js │ │ │ └── csv2chart.js │ │ │ ├── embed-tweet │ │ │ └── embed-tweet.js │ │ │ ├── math │ │ │ └── math.js │ │ │ ├── menu │ │ │ ├── menu.css │ │ │ └── menu.js │ │ │ ├── mermaid │ │ │ └── mermaid.min.js │ │ │ ├── notes │ │ │ ├── notes.html │ │ │ └── notes.js │ │ │ ├── search │ │ │ └── search.js │ │ │ ├── title-footer │ │ │ ├── title-footer-mod.css │ │ │ ├── title-footer.css │ │ │ └── title-footer.js │ │ │ └── zoom-js │ │ │ └── zoom.js │ │ └── font-awesome-4.7.0 │ │ ├── css │ │ └── font-awesome.min.css │ │ └── fonts │ │ └── fontawesome-webfont.woff └── res │ ├── array-java.png │ ├── balanced_tree.svg │ ├── bst.svg │ ├── chrome-memory-bugs.png │ ├── data_structs.png │ ├── hash.jpg │ ├── ids.jpg │ ├── internet-traffic.png │ ├── magistralgor.jpg │ ├── not_balanced_bst.svg │ └── senior.jpg ├── lec_02 ├── index.html ├── libs │ ├── highlight.js │ │ └── 9.12.0 │ │ │ ├── darcula.css │ │ │ ├── darkula.css │ │ │ ├── highlight.js │ │ │ └── reveal-code-focus-1.0.0-mod.js │ └── reveal.js │ │ ├── 3.8.0 │ │ ├── css │ │ │ ├── print │ │ │ │ └── paper.css │ │ │ ├── reveal.css │ │ │ └── theme │ │ │ │ └── Night.css │ │ ├── js │ │ │ └── reveal.js │ │ ├── lib │ │ │ └── js │ │ │ │ └── head.min.js │ │ └── plugin │ │ │ ├── anything │ │ │ └── anything.js │ │ │ ├── chalkboard │ │ │ ├── chalkboard.js │ │ │ └── img │ │ │ │ ├── blackboard.png │ │ │ │ ├── boardmarker.png │ │ │ │ ├── chalk.png │ │ │ │ └── sponge.png │ │ │ ├── chart │ │ │ ├── Chart.min.js │ │ │ └── csv2chart.js │ │ │ ├── embed-tweet │ │ │ └── embed-tweet.js │ │ │ ├── math │ │ │ └── math.js │ │ │ ├── menu │ │ │ ├── menu.css │ │ │ └── menu.js │ │ │ ├── mermaid │ │ │ └── mermaid.min.js │ │ │ ├── notes │ │ │ └── notes.js │ │ │ ├── search │ │ │ └── search.js │ │ │ ├── title-footer │ │ │ ├── title-footer-mod.css │ │ │ ├── title-footer.css │ │ │ └── title-footer.js │ │ │ └── zoom-js │ │ │ └── zoom.js │ │ └── font-awesome-4.7.0 │ │ ├── css │ │ └── font-awesome.min.css │ │ └── fonts │ │ └── fontawesome-webfont.woff └── res │ ├── 01_shared_ptr.svg │ ├── 02_shared_ptr.svg │ ├── 03_shared_ptr.svg │ ├── 04_shared_ptr.svg │ ├── 05_shared_ptr.svg │ ├── 06_shared_ptr.svg │ ├── pointers.png │ └── shared.png ├── lec_03 ├── index.html ├── libs │ ├── highlight.js │ │ └── 9.12.0 │ │ │ ├── darcula.css │ │ │ ├── darkula.css │ │ │ ├── highlight.js │ │ │ └── reveal-code-focus-1.0.0-mod.js │ └── reveal.js │ │ ├── 3.8.0 │ │ ├── css │ │ │ ├── print │ │ │ │ └── paper.css │ │ │ ├── reveal.css │ │ │ └── theme │ │ │ │ └── Night.css │ │ ├── js │ │ │ └── reveal.js │ │ ├── lib │ │ │ └── js │ │ │ │ └── head.min.js │ │ └── plugin │ │ │ ├── anything │ │ │ └── anything.js │ │ │ ├── chalkboard │ │ │ ├── chalkboard.js │ │ │ └── img │ │ │ │ ├── blackboard.png │ │ │ │ ├── boardmarker.png │ │ │ │ ├── chalk.png │ │ │ │ └── sponge.png │ │ │ ├── chart │ │ │ ├── Chart.min.js │ │ │ └── csv2chart.js │ │ │ ├── embed-tweet │ │ │ └── embed-tweet.js │ │ │ ├── math │ │ │ └── math.js │ │ │ ├── menu │ │ │ ├── menu.css │ │ │ └── menu.js │ │ │ ├── mermaid │ │ │ └── mermaid.min.js │ │ │ ├── notes │ │ │ ├── notes.html │ │ │ └── notes.js │ │ │ ├── search │ │ │ └── search.js │ │ │ ├── title-footer │ │ │ ├── title-footer-mod.css │ │ │ ├── title-footer.css │ │ │ └── title-footer.js │ │ │ └── zoom-js │ │ │ └── zoom.js │ │ └── font-awesome-4.7.0 │ │ ├── css │ │ └── font-awesome.min.css │ │ └── fonts │ │ └── fontawesome-webfont.woff └── res │ ├── go-deeper.jpg │ └── shared.png ├── lec_04 ├── index.html ├── libs │ ├── highlight.js │ │ └── 9.12.0 │ │ │ ├── darcula.css │ │ │ ├── darkula.css │ │ │ ├── highlight.js │ │ │ └── reveal-code-focus-1.0.0-mod.js │ └── reveal.js │ │ ├── 3.8.0 │ │ ├── css │ │ │ ├── print │ │ │ │ └── paper.css │ │ │ ├── reveal.css │ │ │ └── theme │ │ │ │ └── Night.css │ │ ├── js │ │ │ └── reveal.js │ │ ├── lib │ │ │ └── js │ │ │ │ └── head.min.js │ │ └── plugin │ │ │ ├── anything │ │ │ └── anything.js │ │ │ ├── chalkboard │ │ │ ├── chalkboard.js │ │ │ └── img │ │ │ │ ├── blackboard.png │ │ │ │ ├── boardmarker.png │ │ │ │ ├── chalk.png │ │ │ │ └── sponge.png │ │ │ ├── chart │ │ │ ├── Chart.min.js │ │ │ └── csv2chart.js │ │ │ ├── embed-tweet │ │ │ └── embed-tweet.js │ │ │ ├── math │ │ │ └── math.js │ │ │ ├── menu │ │ │ ├── menu.css │ │ │ └── menu.js │ │ │ ├── mermaid │ │ │ └── mermaid.min.js │ │ │ ├── notes │ │ │ ├── notes.html │ │ │ └── notes.js │ │ │ ├── search │ │ │ └── search.js │ │ │ ├── title-footer │ │ │ ├── title-footer-mod.css │ │ │ ├── title-footer.css │ │ │ └── title-footer.js │ │ │ └── zoom-js │ │ │ └── zoom.js │ │ └── font-awesome-4.7.0 │ │ ├── css │ │ └── font-awesome.min.css │ │ └── fonts │ │ └── fontawesome-webfont.woff └── res │ ├── cores.jpg │ └── multitask2.jpg ├── lec_05 ├── index.html ├── libs │ ├── highlight.js │ │ └── 9.12.0 │ │ │ ├── darcula.css │ │ │ ├── darkula.css │ │ │ ├── highlight.js │ │ │ └── reveal-code-focus-1.0.0-mod.js │ └── reveal.js │ │ ├── 3.8.0 │ │ ├── css │ │ │ ├── print │ │ │ │ └── paper.css │ │ │ ├── reveal.css │ │ │ └── theme │ │ │ │ └── Blood.css │ │ ├── js │ │ │ └── reveal.js │ │ ├── lib │ │ │ └── js │ │ │ │ └── head.min.js │ │ └── plugin │ │ │ ├── anything │ │ │ └── anything.js │ │ │ ├── chalkboard │ │ │ ├── chalkboard.js │ │ │ └── img │ │ │ │ ├── blackboard.png │ │ │ │ ├── boardmarker.png │ │ │ │ ├── chalk.png │ │ │ │ └── sponge.png │ │ │ ├── chart │ │ │ ├── Chart.min.js │ │ │ └── csv2chart.js │ │ │ ├── embed-tweet │ │ │ └── embed-tweet.js │ │ │ ├── math │ │ │ └── math.js │ │ │ ├── menu │ │ │ ├── menu.css │ │ │ └── menu.js │ │ │ ├── mermaid │ │ │ └── mermaid.min.js │ │ │ ├── notes │ │ │ ├── notes.html │ │ │ └── notes.js │ │ │ ├── search │ │ │ └── search.js │ │ │ ├── title-footer │ │ │ ├── title-footer-mod.css │ │ │ ├── title-footer.css │ │ │ └── title-footer.js │ │ │ └── zoom-js │ │ │ └── zoom.js │ │ └── font-awesome-4.7.0 │ │ ├── css │ │ └── font-awesome.min.css │ │ └── fonts │ │ └── fontawesome-webfont.woff └── res │ ├── li.png │ ├── osi.png │ ├── socket_functions.png │ ├── spiderweb-corner-right.png │ ├── tcp_ip.png │ └── tcp_ip_osi.jpg ├── lec_06 ├── index.html ├── libs │ ├── highlight.js │ │ └── 9.12.0 │ │ │ ├── darcula.css │ │ │ ├── darkula.css │ │ │ ├── highlight.js │ │ │ └── reveal-code-focus-1.0.0-mod.js │ └── reveal.js │ │ ├── 3.8.0 │ │ ├── css │ │ │ ├── print │ │ │ │ └── paper.css │ │ │ ├── reveal.css │ │ │ └── theme │ │ │ │ └── Night.css │ │ ├── js │ │ │ └── reveal.js │ │ ├── lib │ │ │ └── js │ │ │ │ └── head.min.js │ │ └── plugin │ │ │ ├── anything │ │ │ └── anything.js │ │ │ ├── chalkboard │ │ │ ├── chalkboard.js │ │ │ └── img │ │ │ │ ├── blackboard.png │ │ │ │ ├── boardmarker.png │ │ │ │ ├── chalk.png │ │ │ │ └── sponge.png │ │ │ ├── chart │ │ │ ├── Chart.min.js │ │ │ └── csv2chart.js │ │ │ ├── embed-tweet │ │ │ └── embed-tweet.js │ │ │ ├── math │ │ │ └── math.js │ │ │ ├── menu │ │ │ ├── menu.css │ │ │ └── menu.js │ │ │ ├── mermaid │ │ │ └── mermaid.min.js │ │ │ ├── notes │ │ │ └── notes.js │ │ │ ├── search │ │ │ └── search.js │ │ │ ├── title-footer │ │ │ ├── title-footer-mod.css │ │ │ ├── title-footer.css │ │ │ └── title-footer.js │ │ │ └── zoom-js │ │ │ └── zoom.js │ │ └── font-awesome-4.7.0 │ │ ├── css │ │ └── font-awesome.min.css │ │ └── fonts │ │ └── fontawesome-webfont.woff └── res │ ├── deadlock_hire.jpg │ ├── fet.jpg │ ├── lermontov.jpg │ ├── paper.jpg │ ├── pero.jpg │ ├── producer-consumer.svg │ ├── pushkin.jpg │ └── sync.mp4 ├── lec_07 ├── index.html ├── libs │ ├── highlight.js │ │ └── 9.12.0 │ │ │ ├── darcula.css │ │ │ ├── darkula.css │ │ │ ├── highlight.js │ │ │ └── reveal-code-focus-1.0.0-mod.js │ └── reveal.js │ │ ├── 3.8.0 │ │ ├── css │ │ │ ├── print │ │ │ │ └── paper.css │ │ │ ├── reveal.css │ │ │ └── theme │ │ │ │ └── Night.css │ │ ├── js │ │ │ └── reveal.js │ │ ├── lib │ │ │ └── js │ │ │ │ └── head.min.js │ │ └── plugin │ │ │ ├── anything │ │ │ └── anything.js │ │ │ ├── chalkboard │ │ │ ├── chalkboard.js │ │ │ └── img │ │ │ │ ├── blackboard.png │ │ │ │ ├── boardmarker.png │ │ │ │ ├── chalk.png │ │ │ │ └── sponge.png │ │ │ ├── chart │ │ │ ├── Chart.min.js │ │ │ └── csv2chart.js │ │ │ ├── embed-tweet │ │ │ └── embed-tweet.js │ │ │ ├── math │ │ │ └── math.js │ │ │ ├── menu │ │ │ ├── menu.css │ │ │ └── menu.js │ │ │ ├── mermaid │ │ │ └── mermaid.min.js │ │ │ ├── notes │ │ │ ├── notes.html │ │ │ └── notes.js │ │ │ ├── search │ │ │ └── search.js │ │ │ ├── title-footer │ │ │ ├── title-footer-mod.css │ │ │ ├── title-footer.css │ │ │ └── title-footer.js │ │ │ └── zoom-js │ │ │ └── zoom.js │ │ └── font-awesome-4.7.0 │ │ ├── css │ │ └── font-awesome.min.css │ │ └── fonts │ │ └── fontawesome-webfont.woff └── res │ ├── ThreadPool.png │ ├── multitask2.jpg │ ├── oven.jpg │ ├── oven_callback.jpg │ ├── pan.jpg │ └── queue.jpg └── lec_08 ├── index.html ├── libs ├── highlight.js │ └── 9.12.0 │ │ ├── darcula.css │ │ ├── darkula.css │ │ ├── highlight.js │ │ └── reveal-code-focus-1.0.0-mod.js └── reveal.js │ ├── 3.8.0 │ ├── css │ │ ├── print │ │ │ └── paper.css │ │ ├── reveal.css │ │ └── theme │ │ │ └── Night.css │ ├── js │ │ └── reveal.js │ ├── lib │ │ └── js │ │ │ └── head.min.js │ └── plugin │ │ ├── anything │ │ └── anything.js │ │ ├── chalkboard │ │ ├── chalkboard.js │ │ └── img │ │ │ ├── blackboard.png │ │ │ ├── boardmarker.png │ │ │ ├── chalk.png │ │ │ └── sponge.png │ │ ├── chart │ │ ├── Chart.min.js │ │ └── csv2chart.js │ │ ├── embed-tweet │ │ └── embed-tweet.js │ │ ├── math │ │ └── math.js │ │ ├── menu │ │ ├── menu.css │ │ └── menu.js │ │ ├── mermaid │ │ └── mermaid.min.js │ │ ├── notes │ │ ├── notes.html │ │ └── notes.js │ │ ├── search │ │ └── search.js │ │ ├── title-footer │ │ ├── title-footer-mod.css │ │ ├── title-footer.css │ │ └── title-footer.js │ │ └── zoom-js │ │ └── zoom.js │ └── font-awesome-4.7.0 │ ├── css │ └── font-awesome.min.css │ └── fonts │ └── fontawesome-webfont.woff └── res ├── storage_add_block.png ├── storage_after_free.png ├── storage_after_free2.png ├── storage_after_malloc.png ├── storage_after_malloc2.png └── stupid_pool.png /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.suo 4 | *.idb 5 | *.sdf 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | 34 | *.ilk 35 | *.pdb 36 | *.tlog 37 | *.log 38 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "cpp16/lecture-code/lec12/relacy"] 2 | path = cpp16/lecture-code/lec12/relacy 3 | url = https://github.com/dvyukov/relacy 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Лекционный материал по курсу "Современный C++" 2 | 3 | Данный материал читается на кафедре ИУ8 в МГТУ им Н.Э. Баумана. 4 | 5 | ### Содержание 6 | 1. Введение. Структуры данных 7 | 1. Smart pointers [[слайды](https://bmstu-iu8-cpp.github.io/cpp-upper-intermediate/lec_02/index.html#/)] [[код](https://github.com/bmstu-iu8-cpp/cpp-upper-intermediate/tree/master/cpp19/lec_02/source/lec_02_source)] 8 | 1. Многопоточность [[слайды](https://bmstu-iu8-cpp.github.io/cpp-upper-intermediate/lec_04/index.html#/)] [[код](https://github.com/bmstu-iu8-cpp/cpp-upper-intermediate/tree/master/cpp19/lec_04/lec_04_source)] 9 | 1. Сетевое взаимодействие [[слайды](https://bmstu-iu8-cpp.github.io/cpp-upper-intermediate/lec_05/index.html#/)] [[код](https://github.com/bmstu-iu8-cpp/cpp-upper-intermediate/tree/master/cpp19/lec_05/source)] 10 | 1. Синхронизация потоков[[слайды](https://bmstu-iu8-cpp.github.io/cpp-upper-intermediate/lec_06/index.html#/)] [[код](https://github.com/bmstu-iu8-cpp/cpp-upper-intermediate/tree/master/cpp19/lec_06/source)] 11 | 1. Распространенные практики в многопоточном программировании [[слайды](https://bmstu-iu8-cpp.github.io/cpp-upper-intermediate/lec_07/index.html#/)] [[код](https://github.com/bmstu-iu8-cpp/cpp-upper-intermediate/tree/master/cpp19/lec_07)] 12 | 1. Семантика перемещения, шаблоны проектирования [[слайды](https://bmstu-iu8-cpp.github.io/cpp-upper-intermediate/lec_08/index.html#/)] [[код](https://github.com/bmstu-iu8-cpp/cpp-upper-intermediate/blob/master/cpp19/lec_08/source)] 13 | 14 | -------------------------------------------------------------------------------- /cpp16/lecture-code/lec11/main.cpp: -------------------------------------------------------------------------------- 1 | #include "thread_pool.h" 2 | 3 | #include 4 | 5 | void foo(int time) 6 | { 7 | std::cout << "begin on " << std::this_thread::get_id() << std::endl; 8 | std::this_thread::sleep_for(std::chrono::seconds(time)); 9 | std::cout << "end on " << std::this_thread::get_id() << std::endl; 10 | } 11 | 12 | int bar(int time) 13 | { 14 | std::cout << "returns " << time << " on " << std::this_thread::get_id() << std::endl; 15 | return time; 16 | } 17 | 18 | int main() 19 | { 20 | thread_pool pool(8); 21 | 22 | pool.submit(foo, 10); 23 | pool.submit(foo, 10); 24 | pool.submit(foo, 10); 25 | pool.submit(foo, 10); 26 | auto f = pool.submit([](int time) 27 | { 28 | std::cout << "returns " << time << " on " << std::this_thread::get_id() << std::endl; 29 | return time; 30 | }, 10); 31 | pool.submit(bar, 10).get(); 32 | 33 | 34 | std::cout << f.get(); 35 | std::this_thread::sleep_for(std::chrono::seconds(2)); 36 | } -------------------------------------------------------------------------------- /cpp16/lecture-code/lec11/thread_pool.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | 8 | class thread_pool 9 | { 10 | public: 11 | 12 | thread_pool() 13 | { 14 | _start(); 15 | } 16 | 17 | thread_pool(size_t num) : 18 | _num(num) 19 | { 20 | _start(); 21 | } 22 | 23 | ~thread_pool() 24 | { 25 | std::unique_lock lk(_m); 26 | _stop = true; 27 | lk.unlock(); 28 | 29 | cv.notify_all(); 30 | for (auto & t : _threads) 31 | t.join(); 32 | } 33 | 34 | template 35 | std::future> submit(F && func, Args && ... args) 36 | { 37 | using result_type = std::result_of_t; 38 | 39 | auto ptr_task = std::make_shared>( 40 | std::bind(std::forward(func), std::forward(args)... )); 41 | 42 | auto result = ptr_task->get_future(); 43 | 44 | std::lock_guard lk(_m); 45 | _tasks.emplace([ptr_task]() -> void 46 | { 47 | (*ptr_task)(); 48 | }); 49 | 50 | cv.notify_one(); 51 | return result; 52 | } 53 | 54 | private: 55 | size_t _num = std::thread::hardware_concurrency(); 56 | std::queue> _tasks; 57 | std::vector _threads; 58 | std::mutex _m; 59 | std::condition_variable cv; 60 | bool _stop; 61 | 62 | void _working_thread_func() 63 | { 64 | while (true) 65 | { 66 | std::unique_lock lk(_m); 67 | cv.wait(lk, [this]() 68 | { 69 | return _stop || !this->_tasks.empty(); 70 | }); 71 | 72 | if (_stop) 73 | return; 74 | 75 | auto task = _tasks.front(); 76 | _tasks.pop(); 77 | lk.unlock(); 78 | 79 | task(); 80 | } 81 | } 82 | 83 | void _start() 84 | { 85 | _stop = false; 86 | for (size_t i = 0; i < _num; i++) 87 | _threads.push_back(std::thread(&thread_pool::_working_thread_func, this)); 88 | } 89 | }; 90 | -------------------------------------------------------------------------------- /cpp16/lecture-code/lec12/01.cpp: -------------------------------------------------------------------------------- 1 | //#include 2 | //#include 3 | //#include 4 | //#include 5 | // 6 | //// Lock free stack with leaks 7 | // 8 | //template 9 | //class LeakLockFreeStack 10 | //{ 11 | // struct Node 12 | // { 13 | // Node * next = nullptr; 14 | // T data; 15 | // 16 | // Node(const T& v) 17 | // : next(nullptr) 18 | // , data(v) 19 | // { } 20 | // 21 | // Node(const T& v, Node * n) 22 | // : next(n) 23 | // , data(v) 24 | // { } 25 | // }; 26 | // 27 | // std::atomic _head = nullptr; 28 | // 29 | //public: 30 | // LeakLockFreeStack() 31 | // { } 32 | // 33 | // ~LeakLockFreeStack() 34 | // { } 35 | // 36 | // bool try_pop(T & data) 37 | // { 38 | // Node * old_head = _head.load(); 39 | // if (old_head == nullptr) 40 | // { 41 | // return false; 42 | // } 43 | // 44 | // while (old_head && !_head.compare_exchange_strong(old_head, old_head->next)) 45 | // { 46 | // ; // empty loop 47 | // } 48 | // 49 | // if (old_head == nullptr) 50 | // return false; 51 | // // if copy throws exception, then the value will be lost 52 | // data = old_head->data; 53 | // return true; 54 | // } 55 | // 56 | // void push(const T & data) 57 | // { 58 | // Node * new_head = new Node(data, _head.load()); 59 | // 60 | // while (!_head.compare_exchange_strong(new_head->next, new_head)) 61 | // { 62 | // ; // empty loop 63 | // } 64 | // } 65 | //}; 66 | // 67 | // 68 | //int main() 69 | //{ 70 | // LeakLockFreeStack stack; 71 | // 72 | // int i = 0; 73 | // stack.try_pop(i); 74 | // 75 | // stack.push(1); 76 | // stack.push(2); 77 | // 78 | //} 79 | -------------------------------------------------------------------------------- /cpp16/lecture-code/lec12/stack_example_from_rl.cpp: -------------------------------------------------------------------------------- 1 | 2 | #ifdef NDEBUG 3 | # define _SECURE_SCL 0 4 | #endif 5 | 6 | #include "./relacy/relacy\pch.hpp" 7 | 8 | #include "./relacy/relacy\atomic.hpp" 9 | #include "./relacy/relacy\relacy_std.hpp" 10 | 11 | 12 | // TEST FAILS WITH "ACCESS TO FREED MEMORY" 13 | 14 | class stack 15 | { 16 | public: 17 | stack() 18 | : head_(0) 19 | { } 20 | 21 | void push(int data) 22 | { 23 | rl::var n = new node(); 24 | n($)->data_($) = data; 25 | node* next = head_.load(rl::memory_order_relaxed); 26 | for (;;) 27 | { 28 | n($)->next_.store(next, rl::memory_order_relaxed); 29 | if (head_.compare_exchange_weak(next, n($), rl::memory_order_release)) 30 | break; 31 | } 32 | } 33 | 34 | int pop() 35 | { 36 | node* n = head_.load(rl::memory_order_relaxed); 37 | for (;;) 38 | { 39 | if (0 == n) 40 | break; 41 | node* next = n->next_.load(rl::memory_order_relaxed); 42 | if (head_.compare_exchange_weak(n, next, rl::memory_order_acquire)) 43 | break; 44 | } 45 | if (n) 46 | { 47 | int data = n->data_($); 48 | delete n; 49 | return data; 50 | } 51 | else 52 | { 53 | return 0; 54 | } 55 | } 56 | 57 | private: 58 | struct node 59 | { 60 | std::atomic next_; 61 | rl::var data_; 62 | }; 63 | 64 | std::atomic head_; 65 | 66 | stack(stack const&); 67 | stack& operator = (stack const&); 68 | }; 69 | 70 | 71 | 72 | 73 | struct stack_test : rl::test_suite 74 | { 75 | stack s_; 76 | 77 | int produced_count_; 78 | int consumed_count_; 79 | 80 | void before() 81 | { 82 | produced_count_ = 0; 83 | consumed_count_ = 0; 84 | } 85 | 86 | void after() 87 | { 88 | typedef rl::test_suite base_t; 89 | RL_ASSERT(base_t::params::thread_count == produced_count_); 90 | RL_ASSERT(base_t::params::thread_count == consumed_count_); 91 | } 92 | 93 | void thread(unsigned /*index*/) 94 | { 95 | s_.push(rand() + 1); 96 | produced_count_ += 1; 97 | int data = s_.pop(); 98 | RL_ASSERT(data); 99 | consumed_count_ += 1; 100 | } 101 | }; 102 | 103 | 104 | 105 | 106 | int main() 107 | { 108 | rl::simulate(); 109 | return 0; 110 | } 111 | 112 | -------------------------------------------------------------------------------- /cpp16/lecture-code/lec15/01.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | template 6 | struct has_iterator 7 | { 8 | typedef char yes[1]; 9 | typedef char no[2]; 10 | 11 | template 12 | static yes& test(typename C::iterator *); 13 | 14 | template 15 | static no& test(...); 16 | 17 | // If the "sizeof" of the result of calling test(nullptr) is equal to sizeof(yes), 18 | // the first overload worked and T has a nested type named foobar. 19 | static const bool value = sizeof(test(nullptr)) == sizeof(yes); 20 | }; 21 | 22 | 23 | 24 | template 25 | struct is_base_derived 26 | { 27 | typedef char yes[1]; 28 | typedef char no[2]; 29 | 30 | static yes& test(const B &); 31 | 32 | static no& test(...); 33 | 34 | static D makeD(); 35 | 36 | // If the "sizeof" of the result of calling test(nullptr) is equal to sizeof(yes), 37 | // the first overload worked and T has a nested type named foobar. 38 | static const bool value = sizeof(test(makeD())) == sizeof(yes); 39 | }; 40 | 41 | 42 | 43 | template 45 | struct enable_if 46 | { }; 47 | 48 | template 49 | struct enable_if 50 | { 51 | typedef _Ty type; 52 | }; 53 | 54 | 55 | 56 | 57 | template 59 | using enable_if_t = typename enable_if<_Test, _Ty>::type; 60 | 61 | 62 | template 63 | B * creating(enable_if_t::value> * = nullptr) 64 | { 65 | return new D { }; 66 | } 67 | 68 | template 69 | B * creating(enable_if_t::value> * = nullptr) 70 | { 71 | return new B { }; 72 | } 73 | 74 | 75 | struct Base 76 | { 77 | virtual void p() 78 | { 79 | std::cout << "Base" << std::endl; 80 | } 81 | }; 82 | 83 | struct fromBase : public Base 84 | { 85 | void p() override 86 | { 87 | std::cout << "fromBase" << std::endl; 88 | } 89 | }; 90 | int main() 91 | { 92 | 93 | auto ptr = creating(); 94 | ptr->p(); 95 | 96 | ptr = creating(); 97 | ptr->p(); 98 | 99 | std::cout << std::boolalpha; 100 | 101 | std::cout << has_iterator>::value << std::endl; 102 | std::cout << has_iterator::value << std::endl; 103 | 104 | system("pause"); 105 | } -------------------------------------------------------------------------------- /cpp16/lecture-code/lec2/IntVector.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp16/lecture-code/lec2/IntVector.h -------------------------------------------------------------------------------- /cpp16/lecture-code/lec2/lec2.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.40629.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lec2-move_sementics", "lec2_move_semantic.vcxproj", "{2DCFBB61-AD1E-4D79-B83F-EF6EA985501E}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Release|Win32 = Release|Win32 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {2DCFBB61-AD1E-4D79-B83F-EF6EA985501E}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {2DCFBB61-AD1E-4D79-B83F-EF6EA985501E}.Debug|Win32.Build.0 = Debug|Win32 16 | {2DCFBB61-AD1E-4D79-B83F-EF6EA985501E}.Release|Win32.ActiveCfg = Release|Win32 17 | {2DCFBB61-AD1E-4D79-B83F-EF6EA985501E}.Release|Win32.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /cpp16/lecture-code/lec2/lec2_move_semantic.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | 23 | 24 | Header Files 25 | 26 | 27 | -------------------------------------------------------------------------------- /cpp16/lecture-code/lec2/main.cpp: -------------------------------------------------------------------------------- 1 | #include "IntVector.h" 2 | #include 3 | #include 4 | 5 | int main() 6 | { 7 | IntVector v(100); 8 | 9 | IntVector v1 = v; // 10 | v = v1; 11 | 12 | IntVector v2 {std::move(v1)}; 13 | //std::cout << v1.size(); 14 | // if (0 < v1.size()) 15 | // std::cout << v1[0]; 16 | 17 | IntVector v3 = std::move(v); 18 | 19 | v1 = std::move(v3); 20 | 21 | IntVector v4 = {1, 2, 3, 5, 68}; 22 | std::for_each(v4.begin(), v4.end(), [](int i){std::cout << i; }); 23 | 24 | IntVector v5 {1, 2}; 25 | IntVector v6(1, 2); 26 | 27 | auto ptr = IntVector::factory(1000); 28 | auto ptr1 = IntVector::factory(19, 21); 29 | auto ptr2 = IntVector::factory(v6); 30 | auto ptr3 = IntVector::factory(IntVector(1, 2)); 31 | // auto l = {1, 2}; 32 | // auto ptr4 = IntVector::factory(l); 33 | 34 | 35 | std::cout << std::endl; 36 | system("pause"); 37 | } 38 | 39 | -------------------------------------------------------------------------------- /cpp16/lecture-code/lec4/any.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.40629.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "any", "any.vcxproj", "{1F542CE7-8F01-4289-8CAE-2335574FD8E2}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Release|Win32 = Release|Win32 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {1F542CE7-8F01-4289-8CAE-2335574FD8E2}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {1F542CE7-8F01-4289-8CAE-2335574FD8E2}.Debug|Win32.Build.0 = Debug|Win32 16 | {1F542CE7-8F01-4289-8CAE-2335574FD8E2}.Release|Win32.ActiveCfg = Release|Win32 17 | {1F542CE7-8F01-4289-8CAE-2335574FD8E2}.Release|Win32.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /cpp16/lecture-code/lec4/lec4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | template 7 | std::pair make_pair(T t, U u) 8 | { 9 | return std::pair(t, u); 10 | } 11 | 12 | //int main() 13 | //{ 14 | // auto pair = make_pair(10, 10.111); 15 | // std::pair p(10, 10.1111); 16 | //} 17 | 18 | #include "any.h" 19 | 20 | 21 | int main() 22 | { 23 | any a1 = 0; 24 | std::cout << any_cast(a1) << std::endl; 25 | 26 | a1 = static_cast("const cahar pointer"); 27 | std::cout << any_cast(a1) << std::endl; 28 | 29 | a1 = 2.1214214; 30 | std::cout << any_cast(a1) << std::endl; 31 | 32 | a1 = std::string("some test string"); 33 | std::cout << any_cast(a1) << std::endl; 34 | 35 | try 36 | { 37 | std::cout << any_cast(a1) << std::endl; 38 | } 39 | catch (bad_any_cast & e) 40 | { 41 | std::cout << e.what() << std::endl; 42 | } 43 | 44 | std::vector vec = {1, 2, 3}; 45 | a1 = vec; 46 | std::cout << any_cast>(a1).back() << std::endl; 47 | 48 | std::vector vec2 = {1, std::string("asdf"), 3.13241234, 132541.1234}; 49 | 50 | std::for_each(vec2.begin(), vec2.end(), 51 | [](const any & obj) 52 | { 53 | try 54 | { 55 | std::cout << any_cast(obj) << std::endl; 56 | } 57 | catch (bad_any_cast & e) 58 | { 59 | std::cout << e.what() << std::endl; 60 | } 61 | } 62 | ); 63 | } -------------------------------------------------------------------------------- /cpp16/lecture-code/lec6/DebugAllocator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | template 6 | struct DebugAllocator 7 | { 8 | typedef std::size_t size_type; 9 | typedef std::ptrdiff_t difference_type; 10 | typedef T* pointer; 11 | typedef const T* const_pointer; 12 | typedef T& reference; 13 | typedef const T& const_reference; 14 | typedef T value_type; 15 | 16 | DebugAllocator() = default; 17 | 18 | template 19 | DebugAllocator(const DebugAllocator&) { 20 | // from rebind 21 | 22 | } 23 | 24 | ~DebugAllocator() = default; 25 | 26 | T * allocate(std::size_t num) 27 | { 28 | std::cout << "DebugAllocator::alocate " << num << std::endl; 29 | return static_cast(::operator new(num * sizeof(T))); 30 | } 31 | 32 | void deallocate(T * p, std::size_t num) 33 | { 34 | std::cout << "DebugAllocator::dealocate " << num << std::endl; 35 | ::operator delete(p); 36 | } 37 | 38 | // return address of values 39 | T* address(T& value) const 40 | { 41 | return &value; 42 | } 43 | const T* address(const T& value) const 44 | { 45 | return &value; 46 | } 47 | 48 | // return maximum number of elements that can be allocated 49 | std::size_t max_size() const throw() 50 | { 51 | return std::numeric_limits::max() / sizeof(T); 52 | } 53 | 54 | // initialize elements of allocated storage p with value value 55 | void construct(T* p, const T& value) 56 | { 57 | std::cout << "DebugAllocator::construct " << p << std::endl; 58 | // initialize memory with placement new 59 | ::new ((void*)p) T(value); 60 | } 61 | 62 | // destroy elements of initialized storage p 63 | void destroy(T* p) 64 | { 65 | std::cout << "DebugAllocator::destroy " << p << std::endl; 66 | // destroy objects by calling their destructor 67 | p->~T(); 68 | } 69 | 70 | // rebind allocator to type U 71 | template 72 | struct rebind 73 | { 74 | typedef DebugAllocator other; 75 | }; 76 | }; 77 | 78 | template 79 | bool operator== (const DebugAllocator&, 80 | const DebugAllocator&) 81 | { 82 | return true; 83 | } 84 | template 85 | bool operator != (const DebugAllocator&, 86 | const DebugAllocator&) 87 | { 88 | return false; 89 | } 90 | -------------------------------------------------------------------------------- /cpp16/lecture-code/lec6/custom_allocator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "DebugAllocator.h" 3 | #include "TestSpeed.h" 4 | 5 | struct TFoo 6 | { 7 | TFoo() 8 | { 9 | std::cout << "TFoo::TFoo" << std::endl; 10 | } 11 | 12 | TFoo(const TFoo&) 13 | { 14 | std::cout << "TFoo::copy TFoo" << std::endl; 15 | } 16 | ~TFoo() 17 | { 18 | std::cout << "TFoo::~TFoo" << std::endl; 19 | } 20 | double asd = 1.1; 21 | }; 22 | 23 | 24 | struct MyStruct 25 | { 26 | int a = 0; 27 | double qrw = 1234; 28 | std::string adfa = "adsfasd"; 29 | }; 30 | #include 31 | 32 | 33 | int main() 34 | { 35 | 36 | { 37 | std::vector> intVector; 38 | intVector.push_back(TFoo()); 39 | intVector.push_back(TFoo()); 40 | } 41 | return 0; 42 | 43 | 44 | { 45 | TestSpeed::RunTests(); 46 | TestSpeed::RunTests(); 47 | TestSpeed::RunTests(); 48 | } 49 | 50 | return 0; 51 | } -------------------------------------------------------------------------------- /cpp16/lecture-code/lec7/gc.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.40629.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gc", "gc.vcxproj", "{699646ED-4675-4272-A87C-334EA40998DC}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Release|Win32 = Release|Win32 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {699646ED-4675-4272-A87C-334EA40998DC}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {699646ED-4675-4272-A87C-334EA40998DC}.Debug|Win32.Build.0 = Debug|Win32 16 | {699646ED-4675-4272-A87C-334EA40998DC}.Release|Win32.ActiveCfg = Release|Win32 17 | {699646ED-4675-4272-A87C-334EA40998DC}.Release|Win32.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /cpp16/lecture-code/lec7/gc.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /cpp16/lecture-code/lec8/01.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | //1. simple thread 6 | //2. exception in thread 7 | //3. callable item 8 | //4. join or detach 9 | //5. arguments 10 | 11 | 12 | //struct callableObject 13 | //{ 14 | // void operator()() 15 | // { 16 | // std::cout << this << std::endl; 17 | // } 18 | //}; 19 | 20 | 21 | int main() 22 | { 23 | std::cout << std::this_thread::get_id() << std::endl; 24 | std::thread([](){ 25 | std::cout << std::this_thread::get_id() << std::endl; 26 | }).join(); 27 | 28 | /* std::thread(callableObject{}).join(); 29 | std::thread(callableObject{}).join();*/ 30 | return 0; 31 | } -------------------------------------------------------------------------------- /cpp16/lecture-code/lec8/02.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | std::thread([](){ 7 | for (int i = 0; i < 10; i++) 8 | { 9 | std::cout << std::this_thread::get_id() << ":" << i << std::endl; 10 | } 11 | }).detach(); 12 | 13 | std::thread([](){ 14 | for (int i = 0; i < 10; i++) 15 | { 16 | std::cout << std::this_thread::get_id() << ":" << i << std::endl; 17 | } 18 | }).detach(); 19 | 20 | std::thread([](){ 21 | for (int i = 0; i < 10; i++) 22 | { 23 | std::cout << std::this_thread::get_id() << ":" << i << std::endl; 24 | } 25 | }).detach(); 26 | 27 | std::thread([](){ 28 | for (int i = 0; i < 10; i++) 29 | { 30 | std::cout << std::this_thread::get_id() << ":" << i << std::endl; 31 | } 32 | }).join(); 33 | return 0; 34 | } -------------------------------------------------------------------------------- /cpp16/lecture-code/lec8/03.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void foo(std::string & s) 5 | { 6 | s += s; 7 | } 8 | 9 | int main() 10 | { 11 | std::string s = "foo"; 12 | std::thread(foo, s).join(); 13 | std::cout << s.c_str() << std::endl; 14 | 15 | std::thread(foo, std::ref(s)).join(); 16 | std::cout << s.c_str() << std::endl; 17 | return 0; 18 | } -------------------------------------------------------------------------------- /cpp16/lecture-code/lec8/04.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | struct Object 5 | { 6 | std::string name; 7 | void print() const 8 | { 9 | std::cout << name.c_str() << std::endl; 10 | } 11 | 12 | void printMessage(const std::string & message) const 13 | { 14 | std::cout << name.c_str() << ":" << message.c_str() << std::endl; 15 | } 16 | 17 | void getName(std::string & message) const 18 | { 19 | std::cout << "name = " << name.c_str() << std::endl; 20 | message = name; 21 | } 22 | 23 | void change() 24 | { 25 | name += name; 26 | } 27 | }; 28 | 29 | int main() 30 | { 31 | Object o; 32 | o.name = "student"; 33 | 34 | std::thread(&Object::print, o).join(); 35 | 36 | std::string message = "some message"; 37 | std::thread(&Object::printMessage, o, message).join(); 38 | 39 | std::thread(&Object::getName, o, message).join(); 40 | std::cout << message.c_str() << std::endl; 41 | 42 | std::thread(&Object::getName, o, std::ref(message)).join(); 43 | std::cout << message.c_str() << std::endl; 44 | 45 | std::thread(&Object::change, o).join(); 46 | std::cout << o.name.c_str() << std::endl; 47 | 48 | std::thread(&Object::change, std::ref(o)).join(); 49 | std::cout << o.name.c_str() << std::endl; 50 | 51 | return 0; 52 | } -------------------------------------------------------------------------------- /cpp16/lecture-code/lec8/05.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | std::thread t([](){ 7 | std::cout << std::this_thread::get_id() << std::endl; 8 | }); 9 | 10 | t.detach(); 11 | try 12 | { 13 | t.join(); 14 | } 15 | catch (...) 16 | { 17 | std::cout << "opan'ki" << std::endl; 18 | } 19 | 20 | std::thread t2([](){ 21 | std::cout << std::this_thread::get_id() << std::endl; 22 | }); 23 | 24 | t2.detach(); 25 | if (t2.joinable()) 26 | t.join(); 27 | 28 | return 0; 29 | } -------------------------------------------------------------------------------- /cpp16/lecture-code/lec8/06.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void thread_function() 5 | { 6 | std::cout << "thread function\n"; 7 | } 8 | 9 | int main() 10 | { 11 | std::thread t(&thread_function); 12 | 13 | // std::thread t2 = t; // Copying a thread won't compile: 14 | std::thread t2 = std::move(t); // from now t.joinable() returns false 15 | 16 | std::cout << std::boolalpha << t.joinable() << std::endl; 17 | std::cout << std::boolalpha << t2.joinable() << std::endl; 18 | 19 | t2.join(); 20 | 21 | std::cout << std::boolalpha << t.joinable() << std::endl; 22 | std::cout << std::boolalpha << t2.joinable() << std::endl; 23 | 24 | 25 | std::cout << std::endl << std::endl << "creating 2 threads" << std::endl; 26 | t = std::thread(&thread_function); 27 | t2 = std::thread(&thread_function); 28 | 29 | std::cout << std::boolalpha << t.joinable() << std::endl; 30 | std::cout << std::boolalpha << t2.joinable() << std::endl; 31 | t2 = std::move(t); // calling std::terminate() 32 | 33 | return 0; 34 | } -------------------------------------------------------------------------------- /cpp16/lecture-code/lec8/07.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | void thread_function() 7 | { 8 | std::cout << std::this_thread::get_id() << std::endl; 9 | } 10 | 11 | int main() 12 | { 13 | std::vector v; 14 | 15 | for (int u = 0; u < 20; u++) 16 | { 17 | v.push_back(std::thread(thread_function)); 18 | } 19 | std::for_each(v.begin(), v.end(), std::mem_fn(&std::thread::join)); 20 | 21 | return 0; 22 | } -------------------------------------------------------------------------------- /cpp16/lecture-code/lec8/08.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | std::vector vec; 7 | void push() 8 | { 9 | for (int i = 0; i != 10; ++i) 10 | { 11 | std::cout << "Push " << i << std::endl; 12 | std::this_thread::sleep_for(std::chrono::milliseconds(500)); 13 | vec.push_back(i); 14 | } 15 | } 16 | void pop() 17 | { 18 | for (int i = 0; i != 10; ++i) 19 | { 20 | if (vec.size() > 0) 21 | { 22 | int val = vec.back(); 23 | vec.pop_back(); 24 | std::cout << "Pop " << val << std::endl; 25 | } 26 | std::this_thread::sleep_for(std::chrono::milliseconds(500)); 27 | } 28 | } 29 | 30 | int main() 31 | { 32 | //create two threads 33 | std::thread push(push); 34 | std::thread pop(pop); 35 | if (push.joinable()) 36 | push.join(); 37 | if (pop.joinable()) 38 | pop.join(); 39 | 40 | return 0; 41 | } -------------------------------------------------------------------------------- /cpp16/lecture-code/lec8/09.cpp: -------------------------------------------------------------------------------- 1 | // 2 | //#include 3 | //#include 4 | //#include 5 | //#include 6 | //#include 7 | // 8 | //const int count_of_element = 100000000; 9 | //using test_type = double; 10 | // 11 | ///* 12 | // auto start = std::chrono::steady_clock::now(); 13 | // f(s); // execute the function 14 | // return std::chrono::duration_cast( 15 | // std::chrono::steady_clock::now() - start).count(); 16 | //*/ 17 | // 18 | //int main() 19 | //{ 20 | // std::cout << std::thread::hardware_concurrency() << std::endl; 21 | // { 22 | // auto start = std::chrono::steady_clock::now(); 23 | // std::vector data(count_of_element, test_type { }); 24 | // test_type res{}; 25 | // for (auto i = 0; i < data.size(); i++) 26 | // { 27 | // res += data[i]; 28 | // } 29 | // std::cout << std::chrono::duration_cast( 30 | // std::chrono::steady_clock::now() - start).count() << std::endl; 31 | // } 32 | // 33 | // auto start1 = std::chrono::steady_clock::now(); 34 | // //auto l = ; 35 | // 36 | // std::thread t1([](){ 37 | // std::vector data(count_of_element / 4, test_type { }); 38 | // test_type res { }; 39 | // 40 | // for (auto i = 0; i < data.size(); i++) 41 | // { 42 | // res += data[i]; 43 | // } 44 | // }); 45 | // std::thread t2([](){ 46 | // std::vector data(count_of_element / 4, test_type { }); 47 | // test_type res { }; 48 | // 49 | // for (auto i = 0; i < data.size(); i++) 50 | // { 51 | // res += data[i]; 52 | // } 53 | // }); 54 | // std::thread t3([](){ 55 | // std::vector data(count_of_element / 4, test_type { }); 56 | // test_type res { }; 57 | // 58 | // for (auto i = 0; i < data.size(); i++) 59 | // { 60 | // res += data[i]; 61 | // } 62 | // }); 63 | // std::thread t4([](){ 64 | // std::vector data(count_of_element / 4, test_type { }); 65 | // test_type res{}; 66 | // 67 | // for (auto i = 0; i < data.size(); i++) 68 | // { 69 | // res += data[i]; 70 | // } 71 | // }); 72 | // 73 | // 74 | // t1.join(); 75 | // t2.join(); 76 | // t3.join(); 77 | // t4.join(); 78 | // std::cout << std::chrono::duration_cast( 79 | // std::chrono::steady_clock::now() - start1).count() << std::endl; 80 | // 81 | // system("pause"); 82 | // return 0; 83 | //} -------------------------------------------------------------------------------- /cpp16/lecture-code/lec8/10.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | std::mutex m; 8 | std::vector vec; 9 | 10 | void push() 11 | { 12 | for (int i = 0; i != 100; ++i) 13 | { 14 | std::this_thread::sleep_for(std::chrono::milliseconds(500)); 15 | vec.push_back(i); 16 | } 17 | } 18 | 19 | void pop() 20 | { 21 | for (int i = 0; i != 50; ++i) 22 | { 23 | { 24 | std::lock_guard lk(m); 25 | if (vec.size() > 0) 26 | { 27 | int val = vec.back(); 28 | vec.pop_back(); 29 | std::cout << "Pop[" << std::this_thread::get_id() << "] " << val << std::endl; 30 | } 31 | } // unlock mutex 32 | std::this_thread::sleep_for(std::chrono::milliseconds(300)); 33 | } 34 | } 35 | 36 | void bad_pop() 37 | { 38 | for (int i = 0; i != 50; ++i) 39 | { 40 | if (vec.size() > 0) 41 | { 42 | int val = vec.back(); 43 | vec.pop_back(); 44 | std::cout << "Pop[" << std::this_thread::get_id() << "] " << val << std::endl; 45 | } 46 | std::this_thread::sleep_for(std::chrono::milliseconds(500)); 47 | } 48 | } 49 | 50 | 51 | int main() 52 | { 53 | //create two threads 54 | std::thread push(push); 55 | std::thread thread_pop_a(pop); 56 | std::thread thread_pop_b(pop); 57 | if (push.joinable()) 58 | push.join(); 59 | if (thread_pop_a.joinable()) 60 | thread_pop_a.join(); 61 | if (thread_pop_b.joinable()) 62 | thread_pop_b.join(); 63 | 64 | return 0; 65 | } -------------------------------------------------------------------------------- /cpp16/lecture-code/lec8/11.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | void dead_lock() 8 | { 9 | std::mutex m_a; 10 | std::mutex m_b; 11 | 12 | std::lock_guard lk_a(m_a); 13 | std::thread t_a([&m_a, &m_b](){ 14 | std::lock_guard lk_a(m_a); 15 | std::this_thread::sleep_for(std::chrono::milliseconds(500)); 16 | std::lock_guard lk_b(m_b); 17 | }); 18 | 19 | std::thread t_b([&m_a, &m_b](){ 20 | std::lock(m_a, m_b); 21 | std::lock_guard lk_b(m_b); 22 | std::this_thread::sleep_for(std::chrono::milliseconds(500)); 23 | std::lock_guard lk_a(m_a); 24 | }); 25 | 26 | t_a.join(); 27 | t_b.join(); 28 | } 29 | 30 | int main() 31 | { 32 | std::thread t([]() { 33 | while(true) { 34 | std::cout << "."; 35 | std::this_thread::sleep_for(std::chrono::milliseconds(100)); 36 | } 37 | }); 38 | 39 | std::thread(dead_lock).join(); 40 | 41 | t.detach(); 42 | 43 | return 0; 44 | } -------------------------------------------------------------------------------- /cpp16/lecture-code/lec8/12.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | std::mutex m; 8 | std::vector vec; 9 | 10 | void push() 11 | { 12 | for (int i = 0; i != 100; ++i) 13 | { 14 | std::this_thread::sleep_for(std::chrono::milliseconds(500)); 15 | std::lock_guard lk(m); 16 | vec.push_back(i); 17 | } 18 | } 19 | 20 | void pop() 21 | { 22 | for (int i = 0; i != 50; ++i) 23 | { 24 | std::unique_lock lk(m); 25 | if (vec.size() > 0) 26 | { 27 | int val = vec.back(); 28 | vec.pop_back(); 29 | std::cout << "Pop[" << std::this_thread::get_id() << "] " << val << std::endl; 30 | } 31 | lk.unlock(); 32 | std::this_thread::sleep_for(std::chrono::milliseconds(300)); 33 | } 34 | } 35 | 36 | std::unique_lock pass_own(std::unique_lock lx) 37 | { 38 | if (lx) 39 | { 40 | std::cout << "unlocking" << std::endl; 41 | lx.unlock(); 42 | } 43 | return lx; 44 | } 45 | 46 | 47 | int main() 48 | { 49 | // just testing unique_lock 50 | std::mutex local_mutex; 51 | std::unique_lock lx(local_mutex, std::defer_lock); 52 | lx = pass_own(std::move(lx)); 53 | lx.lock(); 54 | lx = pass_own(std::move(lx)); 55 | auto successed = lx.try_lock(); 56 | std::cout << std::boolalpha << successed << std::endl; 57 | std::cout << std::boolalpha << pass_own(std::move(lx)).owns_lock() << std::endl; 58 | 59 | 60 | //create two threads 61 | std::thread push(push); 62 | std::thread thread_pop_a(pop); 63 | std::thread thread_pop_b(pop); 64 | if (push.joinable()) 65 | push.join(); 66 | if (thread_pop_a.joinable()) 67 | thread_pop_a.join(); 68 | if (thread_pop_b.joinable()) 69 | thread_pop_b.join(); 70 | 71 | 72 | return 0; 73 | } -------------------------------------------------------------------------------- /cpp16/lecture-code/lec8/13.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | class Foo 10 | { 11 | boost::shared_mutex _m; 12 | std::vector _v; 13 | 14 | public: 15 | int read_size() 16 | { 17 | // many threads can read data, so use shared_lock 18 | boost::shared_lock lk(_m); 19 | std::this_thread::sleep_for(std::chrono::milliseconds(1000)); 20 | return _v.size(); 21 | } 22 | 23 | void add_value() 24 | { 25 | // only one thread can write data, so use lock_guard 26 | std::lock_guard lk(_m); 27 | std::this_thread::sleep_for(std::chrono::milliseconds(1000)); 28 | _v.push_back(42); 29 | } 30 | }; 31 | 32 | void read(Foo &f) 33 | { 34 | for (int i = 0; i != 100; ++i) 35 | { 36 | std::cout << f.read_size() << std::endl; 37 | std::this_thread::sleep_for(std::chrono::milliseconds(100)); 38 | } 39 | } 40 | 41 | void write(Foo &f) 42 | { 43 | for (int i = 0; i != 10; ++i) 44 | { 45 | std::cout << "added" << std::endl; 46 | f.add_value(); 47 | std::this_thread::sleep_for(std::chrono::milliseconds(100)); 48 | } 49 | } 50 | 51 | int main() 52 | { 53 | Foo f; 54 | 55 | std::thread(read, std::ref(f)).detach(); 56 | std::thread(read, std::ref(f)).detach(); 57 | std::thread(read, std::ref(f)).detach(); 58 | std::thread(read, std::ref(f)).detach(); 59 | std::thread(write, std::ref(f)).join(); 60 | 61 | return 0; 62 | } -------------------------------------------------------------------------------- /cpp16/lecture-code/lec8/14.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #if _MSC_VER <= 1800 5 | // VS 2013 doesn't support thread_local keyword 6 | #define thread_local __declspec(thread) 7 | #endif 8 | 9 | static thread_local unsigned int thread_var = 0; 10 | static unsigned int global_var = 0; 11 | 12 | void foo_thread() 13 | { 14 | for (int i = 0; i < 10; i++) 15 | { 16 | std::cout << std::this_thread::get_id() << ":" << thread_var++ << std::endl; 17 | std::this_thread::sleep_for(std::chrono::milliseconds(100)); 18 | } 19 | } 20 | 21 | 22 | void foo_global() 23 | { 24 | for (int i = 0; i < 10; i++) 25 | { 26 | std::cout << std::this_thread::get_id() << ":" << global_var++ << std::endl; 27 | std::this_thread::sleep_for(std::chrono::milliseconds(100)); 28 | } 29 | } 30 | 31 | 32 | int main() 33 | { 34 | 35 | std::thread(foo_global).detach(); 36 | std::thread(foo_global).detach(); 37 | std::thread(foo_global).detach(); 38 | std::thread(foo_global).detach(); 39 | std::thread(foo_global).join(); 40 | std::cout << "GLOBAL = " << global_var << std::endl; 41 | std::cout << "----------------------------" << std::endl; 42 | 43 | 44 | std::thread(foo_thread).detach(); 45 | std::thread(foo_thread).detach(); 46 | std::thread(foo_thread).detach(); 47 | std::thread(foo_thread).detach(); 48 | std::thread(foo_thread).join(); 49 | std::cout << "THREAD = " << thread_var << std::endl; 50 | 51 | return 0; 52 | } -------------------------------------------------------------------------------- /cpp16/lecture-code/lec9/00.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | // Demonstrate data race 9 | 10 | unsigned long long g_sum = 0; 11 | 12 | void summ(unsigned long long a, unsigned long long b) 13 | { 14 | for (unsigned long long i = a; i < b; i++) 15 | { 16 | g_sum = g_sum + i; 17 | } 18 | } 19 | 20 | int main() 21 | { 22 | const unsigned long long n = 10000000; 23 | 24 | std::thread t1(summ, 0, n); 25 | std::thread t2(summ, n, 2 * n); 26 | std::thread t3(summ, 2 * n, 3 * n); 27 | std::thread t4(summ, 3 * n, (4 * n) + 1); 28 | 29 | t1.join(); 30 | t2.join(); 31 | t3.join(); 32 | t4.join(); 33 | 34 | std::cout << "summ = " << g_sum << std::endl; 35 | std::cout << "answer = " << (n * 4) * (4 * n + 1) / 2 << std::endl; 36 | 37 | 38 | return 0; 39 | } -------------------------------------------------------------------------------- /cpp16/lecture-code/lec9/01.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | // cv simple sample 6 | 7 | std::mutex m; 8 | bool flag = false; 9 | std::condition_variable cv; 10 | 11 | void waiting_cv() 12 | { 13 | std::unique_lock lk(m); 14 | 15 | cv.wait(lk, [](){ 16 | std::cout << ".."; 17 | return flag; 18 | }); 19 | 20 | // using flag 21 | std::cout << std::endl << std::boolalpha << flag; 22 | } 23 | 24 | void process() 25 | { 26 | std::lock_guard lk(m); 27 | std::this_thread::sleep_for(std::chrono::milliseconds(500)); // some action 28 | flag = true; 29 | cv.notify_one(); // data is ready 30 | } 31 | 32 | int main() 33 | { 34 | std::thread t1(waiting_cv); 35 | std::thread t2(process); 36 | 37 | t1.join(); 38 | t2.join(); 39 | 40 | return 0; 41 | } -------------------------------------------------------------------------------- /cpp16/lecture-code/lec9/02.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | // cv simple sample. testing queue 7 | 8 | std::mutex m; 9 | std::queue q; 10 | std::condition_variable cv; 11 | 12 | void waiting_cv() 13 | { 14 | int r = -1; 15 | while (r != 9) 16 | { 17 | std::unique_lock lk(m); 18 | cv.wait(lk, [](){ 19 | std::cout << ".."; 20 | return !q.empty(); 21 | }); // wait while q.empty() 22 | 23 | // lk is already locked 24 | // we can using queue 25 | r = q.front(); 26 | q.pop(); 27 | lk.unlock(); 28 | 29 | std::cout << std::endl << std::boolalpha << r; 30 | std::this_thread::sleep_for(std::chrono::milliseconds(100)); // some action 31 | } 32 | } 33 | 34 | void waiting_for_cv() 35 | { 36 | int r = -1; 37 | while (r != 9) 38 | { 39 | std::unique_lock lk(m); 40 | 41 | // wait for 100 milliseconds 42 | auto pred_result = cv.wait_for(lk, 43 | std::chrono::milliseconds(100), 44 | [](){ 45 | std::cout << ".."; 46 | return !q.empty(); 47 | }); 48 | 49 | if (!pred_result) // if q.empty() continue; else we can using queue 50 | continue; 51 | 52 | // lk is already locked 53 | // we can using queue 54 | r = q.front(); 55 | q.pop(); 56 | lk.unlock(); 57 | 58 | std::cout << std::endl << std::boolalpha << r; 59 | std::this_thread::sleep_for(std::chrono::milliseconds(100)); // some action 60 | } 61 | } 62 | 63 | void process() 64 | { 65 | int i = 0; 66 | while (i < 10) 67 | { 68 | std::this_thread::sleep_for(std::chrono::milliseconds(500)); // some action 69 | std::lock_guard lk(m); // lock 70 | q.push(i++); // push data 71 | cv.notify_one(); // data is ready 72 | } 73 | } 74 | 75 | int main() 76 | { 77 | std::thread t1(waiting_cv); 78 | std::thread t2(process); 79 | 80 | t1.join(); 81 | t2.join(); 82 | 83 | return 0; 84 | } -------------------------------------------------------------------------------- /cpp16/lecture-code/lec9/03.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | // future & async simple sample 7 | 8 | 9 | int getting_data() 10 | { 11 | std::this_thread::sleep_for(std::chrono::milliseconds(10000)); 12 | return 42; 13 | } 14 | 15 | int getting_data_quick(int i) 16 | { 17 | return i * i; 18 | } 19 | 20 | void tick() 21 | { 22 | int i = 10; 23 | while (i) 24 | { 25 | std::cout << "."; 26 | i--; 27 | std::this_thread::sleep_for(std::chrono::milliseconds(1000)); 28 | } 29 | } 30 | 31 | int main() 32 | { 33 | std::thread t1(tick); // tick 1s 34 | std::future f = std::async(std::launch::async, getting_data); // launching a long time operation 35 | // std::future f = std::async(std::launch::deferred, getting_data); // deferred launching a long time operation 36 | // std::future f = std::async(std::launch::async, getting_data_quick, 10); // launching a quick time operation 37 | 38 | std::cout << std::boolalpha << f.valid() << std::endl; 39 | 40 | std::this_thread::sleep_for(std::chrono::milliseconds(5000)); // performs other actions 41 | 42 | auto i = f.get(); // getting result 43 | std::cout << i << std::endl; 44 | std::cout << std::boolalpha << f.valid() << std::endl; 45 | 46 | t1.join(); 47 | return 0; 48 | } -------------------------------------------------------------------------------- /cpp16/lecture-code/lec9/03a.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | // future & async simple sample 7 | 8 | int getting_data() 9 | { 10 | std::this_thread::sleep_for(std::chrono::seconds(3)); 11 | return 42; 12 | } 13 | 14 | void print_future(std::shared_future f) 15 | { 16 | std::this_thread::sleep_for(std::chrono::milliseconds(500)); 17 | std::cout << f.get() << std::endl; 18 | } 19 | 20 | void tick() 21 | { 22 | int i = 4; 23 | while (i) 24 | { 25 | std::cout << "."; 26 | i--; 27 | std::this_thread::sleep_for(std::chrono::milliseconds(1000)); 28 | } 29 | } 30 | 31 | int main() 32 | { 33 | std::thread t1(tick); // tick 1s 34 | auto sf = std::async(std::launch::async, getting_data).share(); 35 | 36 | std::thread t2(print_future, sf); 37 | std::thread t3(print_future, sf); 38 | std::thread t4(print_future, sf); 39 | 40 | t1.join(); 41 | t2.join(); 42 | t3.join(); 43 | t4.join(); 44 | return 0; 45 | } -------------------------------------------------------------------------------- /cpp16/lecture-code/lec9/04.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | // catch exception from thread 7 | 8 | 9 | int getting_data() 10 | { 11 | std::this_thread::sleep_for(std::chrono::milliseconds(3000)); 12 | 13 | throw 42; 14 | return 42; 15 | } 16 | 17 | void tick() 18 | { 19 | int i = 10; 20 | while (i) 21 | { 22 | std::cout << "."; 23 | i--; 24 | std::this_thread::sleep_for(std::chrono::seconds(1)); 25 | } 26 | } 27 | 28 | int main() 29 | { 30 | std::thread t1(tick); // tick 1s 31 | std::future f = std::async(std::launch::async, getting_data); 32 | 33 | try 34 | { 35 | auto i = f.get(); // getting result 36 | std::cout << i << std::endl; 37 | } 38 | catch (int i) 39 | { 40 | std::cout << "catch " << i << std::endl; 41 | } 42 | 43 | t1.join(); 44 | return 0; 45 | } -------------------------------------------------------------------------------- /cpp16/lecture-code/lec9/05.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | // std::promise simple sample 9 | 10 | void accumulate(std::vector::iterator first, 11 | std::vector::iterator last, 12 | std::promise& accumulate_promise) 13 | { 14 | int sum = std::accumulate(first, last, 0); 15 | accumulate_promise.set_value(sum); // Notify future 16 | } 17 | 18 | int main() 19 | { 20 | std::vector data {0, 1, 2, 3, 4, 6, 7, 132, 134}; 21 | std::promise pr; 22 | 23 | auto f = pr.get_future(); 24 | std::thread t1(accumulate, data.begin(), data.end(), 25 | std::ref(pr)); 26 | 27 | f.wait(); 28 | 29 | std::cout << f.get() << std::endl; 30 | t1.join(); 31 | return 0; 32 | } -------------------------------------------------------------------------------- /cpp16/lecture-code/lec9/06.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | // Demonstrate using promise to signal state between threads. 9 | 10 | void source(std::promise & p) 11 | { 12 | std::this_thread::sleep_for(std::chrono::seconds(1)); 13 | p.set_value(); 14 | } 15 | 16 | void destination(std::future & f) 17 | { 18 | f.wait(); 19 | std::cout << "a signal from source is received" << std::endl; 20 | } 21 | 22 | int main() 23 | { 24 | std::promise p; 25 | 26 | auto f = p.get_future(); 27 | std::thread t1(source, 28 | std::ref(p)); // use std::move(p) if 'source' takes p by value 29 | std::thread t2(destination, 30 | std::ref(f)); // use std::move(f) if 'destination' takes f by value 31 | 32 | t1.join(); 33 | t2.join(); 34 | return 0; 35 | } -------------------------------------------------------------------------------- /cpp16/lecture-code/lec9/07.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | // throw exception 9 | 10 | void source(std::promise & p) 11 | { 12 | try 13 | { 14 | std::this_thread::sleep_for(std::chrono::seconds(1)); 15 | throw 42; 16 | p.set_value(); 17 | } 18 | catch (...) 19 | { 20 | p.set_exception(std::current_exception()); 21 | } 22 | } 23 | 24 | void destination(std::future & f) 25 | { 26 | try 27 | { 28 | // f.wait(); // doesn't throw exception 29 | f.get(); // throw exception 30 | std::cout << "a signal from source is received" << std::endl; 31 | } 32 | catch (int i) 33 | { 34 | std::cout << "catch " << i << std::endl; 35 | } 36 | 37 | } 38 | 39 | int main() 40 | { 41 | std::promise p; 42 | 43 | auto f = p.get_future(); 44 | std::thread t1(source, std::ref(p)); 45 | std::thread t2(destination, std::ref(f)); 46 | 47 | t1.join(); 48 | t2.join(); 49 | return 0; 50 | } -------------------------------------------------------------------------------- /cpp16/lecture-code/lec9/08.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | // Demonstrate using std::packaged_task 9 | 10 | using packaged_task_and_arg = std::pair, double>; 11 | 12 | void sequence_invoke(std::vector& v) 13 | { 14 | for (auto & p : v) 15 | { 16 | p.first(p.second); 17 | } 18 | } 19 | 20 | 21 | void some_stupid_sample() 22 | { 23 | auto lambda = [](double d) -> double { 24 | std::this_thread::sleep_for(std::chrono::milliseconds(100)); 25 | return d * d; 26 | }; 27 | 28 | std::vector arr; 29 | 30 | for (int i = 1; i <= 6; i++) 31 | { 32 | arr.push_back({std::packaged_task(lambda), 10. * i}); 33 | } 34 | 35 | std::vector> futures; 36 | 37 | for (auto & pt : arr) 38 | futures.push_back(pt.first.get_future()); 39 | 40 | std::thread(sequence_invoke, std::ref(arr)).detach(); 41 | 42 | std::cout << futures[futures.size() - 1].get() << std::endl; 43 | } 44 | 45 | void simple_sample() 46 | { 47 | std::packaged_task pt( 48 | [](double d) -> double { 49 | std::this_thread::sleep_for(std::chrono::seconds(1)); 50 | return d * d; 51 | }); 52 | 53 | auto f = pt.get_future(); 54 | 55 | std::thread(std::move(pt), 10.).detach(); 56 | 57 | std::cout << f.get() << std::endl; 58 | } 59 | 60 | int main() 61 | { 62 | simple_sample(); 63 | 64 | some_stupid_sample(); 65 | 66 | return 0; 67 | } -------------------------------------------------------------------------------- /cpp16/lecture-slides/lec10_atomic.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp16/lecture-slides/lec10_atomic.pdf -------------------------------------------------------------------------------- /cpp16/lecture-slides/lec11_threadPool.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp16/lecture-slides/lec11_threadPool.pdf -------------------------------------------------------------------------------- /cpp16/lecture-slides/lec12_lockFree.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp16/lecture-slides/lec12_lockFree.pdf -------------------------------------------------------------------------------- /cpp16/lecture-slides/lec14_network.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp16/lecture-slides/lec14_network.pdf -------------------------------------------------------------------------------- /cpp16/lecture-slides/lec15_sfinae_pimpl.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp16/lecture-slides/lec15_sfinae_pimpl.pdf -------------------------------------------------------------------------------- /cpp16/lecture-slides/lec1_introCpp11.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp16/lecture-slides/lec1_introCpp11.pdf -------------------------------------------------------------------------------- /cpp16/lecture-slides/lec2_rvalues.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp16/lecture-slides/lec2_rvalues.pdf -------------------------------------------------------------------------------- /cpp16/lecture-slides/lec4_introCpp17.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp16/lecture-slides/lec4_introCpp17.pdf -------------------------------------------------------------------------------- /cpp16/lecture-slides/lec5_smartPointers.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp16/lecture-slides/lec5_smartPointers.pdf -------------------------------------------------------------------------------- /cpp16/lecture-slides/lec6_memory_managment.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp16/lecture-slides/lec6_memory_managment.pdf -------------------------------------------------------------------------------- /cpp16/lecture-slides/lec7_garbage_collection.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp16/lecture-slides/lec7_garbage_collection.pdf -------------------------------------------------------------------------------- /cpp16/lecture-slides/lec8_introMultithreading.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp16/lecture-slides/lec8_introMultithreading.pdf -------------------------------------------------------------------------------- /cpp16/lecture-slides/lec9_async.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp16/lecture-slides/lec9_async.pdf -------------------------------------------------------------------------------- /cpp17/lectures/01_introduction/introduction.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp17/lectures/01_introduction/introduction.pdf -------------------------------------------------------------------------------- /cpp17/lectures/02_move_semantics/move_semantics.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp17/lectures/02_move_semantics/move_semantics.pdf -------------------------------------------------------------------------------- /cpp17/lectures/02_move_semantics/sources/01.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | struct MyStruct 4 | { 5 | MyStruct() 6 | { 7 | std::cout << "default ctor" << std::endl; 8 | } 9 | 10 | MyStruct(const MyStruct& oth) 11 | { 12 | std::cout << "copy ctor" << std::endl; 13 | } 14 | 15 | MyStruct(MyStruct&& oth) 16 | { 17 | std::cout << "move ctor" << std::endl; 18 | } 19 | 20 | MyStruct& operator=(MyStruct&& oth) 21 | { 22 | if (&oth == this) 23 | return *this; 24 | std::cout << "move operator" << std::endl; 25 | return *this; 26 | } 27 | 28 | MyStruct& operator=(const MyStruct& oth) 29 | { 30 | if (&oth == this) 31 | return *this; 32 | std::cout << "copy operator" << std::endl; 33 | return *this; 34 | } 35 | 36 | ~MyStruct() 37 | { 38 | std::cout << "dtor" << std::endl; 39 | } 40 | }; 41 | 42 | MyStruct createStruct() 43 | { 44 | return MyStruct(); 45 | } 46 | 47 | int main() 48 | { 49 | MyStruct a; 50 | MyStruct b(a); 51 | MyStruct c(std::move(a)); 52 | b = c; 53 | c = std::move(b); 54 | c = createStruct(); 55 | system("pause"); 56 | } -------------------------------------------------------------------------------- /cpp17/lectures/02_move_semantics/sources/02.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #pragma warning(disable:4996) 4 | 5 | class String 6 | { 7 | char * data = nullptr; 8 | public: 9 | String(const String& rhs) 10 | { 11 | if (!rhs.data) 12 | return; 13 | 14 | data = new char[strlen(rhs.data) + 1]; 15 | strcpy(data, rhs.data); 16 | } 17 | 18 | String(String&& rhs) 19 | { 20 | data = rhs.data; 21 | rhs.data = nullptr; 22 | // shorter std::swap(data, rhs.data); 23 | } 24 | 25 | String(const char * const str) 26 | { 27 | data = new char[strlen(str) + 1]; 28 | strcpy(data, str); 29 | } 30 | 31 | ~String() 32 | { 33 | // need to implement!!! 34 | } 35 | }; 36 | 37 | int main() 38 | { 39 | { 40 | String s("string"); 41 | String t = s; 42 | String u = std::move(s); 43 | } 44 | } -------------------------------------------------------------------------------- /cpp17/lectures/02_move_semantics/sources/03.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | struct MyStruct 4 | { 5 | MyStruct() 6 | { 7 | std::cout << "default ctor" << std::endl; 8 | } 9 | 10 | MyStruct(const MyStruct& oth) 11 | { 12 | std::cout << "copy ctor" << std::endl; 13 | } 14 | 15 | MyStruct(MyStruct&& oth) 16 | { 17 | std::cout << "move ctor" << std::endl; 18 | } 19 | 20 | MyStruct& operator=(MyStruct&& oth) 21 | { 22 | if (&oth == this) 23 | return *this; 24 | std::cout << "move operator" << std::endl; 25 | return *this; 26 | } 27 | 28 | MyStruct& operator=(const MyStruct& oth) 29 | { 30 | if (&oth == this) 31 | return *this; 32 | std::cout << "copy operator" << std::endl; 33 | return *this; 34 | } 35 | 36 | ~MyStruct() 37 | { 38 | std::cout << "dtor" << std::endl; 39 | } 40 | }; 41 | 42 | MyStruct createStruct() 43 | { 44 | return MyStruct(); 45 | } 46 | 47 | template 48 | void foo(T&& obj) 49 | { 50 | MyStruct st(obj); 51 | } 52 | 53 | template 54 | void bar(T&& obj) 55 | { 56 | MyStruct st(std::forward(obj)); 57 | } 58 | 59 | int main() 60 | { 61 | MyStruct a; 62 | foo(a); 63 | foo(createStruct()); 64 | 65 | 66 | MyStruct b; 67 | bar(b); 68 | bar(createStruct()); 69 | 70 | system("pause"); 71 | } -------------------------------------------------------------------------------- /cpp17/lectures/02_move_semantics/sources/04.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | struct Sentence 6 | { 7 | std::vector data; 8 | 9 | template 10 | void add_word(T&& word) 11 | { 12 | data.push_back(std::forward(word)); 13 | } 14 | 15 | friend std::ostream& operator << (std::ostream& out, const Sentence& sent); 16 | }; 17 | 18 | std::string world_word() 19 | { 20 | return std::string("World"); 21 | } 22 | 23 | int main() 24 | { 25 | Sentence s; 26 | std::string hello = "hello"; 27 | s.add_word(hello); 28 | s.add_word(","); 29 | s.add_word(world_word()); 30 | 31 | std::cout << s; 32 | } 33 | 34 | std::ostream& operator << (std::ostream& out, const Sentence& sent) 35 | { 36 | for (const auto& w : sent.data) 37 | out << w << " "; 38 | return out; 39 | } 40 | -------------------------------------------------------------------------------- /cpp17/lectures/02_move_semantics/sources/05.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | struct Animal 6 | { 7 | Animal(const char * str, size_t a) 8 | : name(str) 9 | , age(a) 10 | { } 11 | 12 | std::string name; 13 | size_t age; 14 | }; 15 | 16 | template 17 | Animal create_animal(Args&&... args) 18 | { 19 | return Animal(std::forward(args)...); 20 | } 21 | 22 | int main() 23 | { 24 | std::vector zoo; 25 | zoo.push_back(Animal("cat", 10)); 26 | zoo.emplace_back("dog", 3); 27 | 28 | auto b = create_animal("bird", 1); 29 | std::cout << b.name; 30 | } -------------------------------------------------------------------------------- /cpp17/lectures/03_smart_pointers/smart_pointers.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp17/lectures/03_smart_pointers/smart_pointers.pdf -------------------------------------------------------------------------------- /cpp17/lectures/03_smart_pointers/sources/01.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | struct Object 5 | { 6 | int data[10000]; 7 | 8 | void Print() const 9 | { 10 | std::cout << "some message" << std::endl; 11 | } 12 | }; 13 | 14 | 15 | int main() 16 | { 17 | { 18 | Object * obj = new Object(); 19 | obj->Print(); 20 | // memory leak 21 | } 22 | 23 | { 24 | auto obj = std::make_unique(); 25 | obj->Print(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /cpp17/lectures/03_smart_pointers/sources/02.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | 6 | void foo(std::unique_ptr> ptr) 7 | { 8 | std::cout << ptr->size() << std::endl; 9 | } 10 | 11 | int main() 12 | { 13 | auto ptr = std::make_unique>(100000); 14 | std::cout << std::boolalpha << static_cast(ptr) << std::endl; 15 | 16 | // foo(ptr); // ptr is lvalue. error 17 | foo(std::move(ptr)); 18 | 19 | std::cout << std::boolalpha << static_cast(ptr) << std::endl; 20 | 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /cpp17/lectures/03_smart_pointers/sources/03.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | struct Object 5 | { 6 | ~Object() 7 | { 8 | std::cout << "~Object" << std::endl; 9 | } 10 | void Print() const 11 | { 12 | std::cout << "some message" << std::endl; 13 | } 14 | }; 15 | 16 | int main() 17 | { 18 | auto ptrOne = std::make_shared(); 19 | std::cout << ptrOne.use_count() << std::endl; 20 | std::cout << std::boolalpha << ptrOne.unique() << std::endl; 21 | 22 | auto ptrTwo = ptrOne; 23 | std::cout << ptrOne.use_count() << std::endl; 24 | std::cout << std::boolalpha << ptrOne.unique() << std::endl; 25 | 26 | auto ptrThree = ptrOne; 27 | std::cout << ptrOne.use_count() << std::endl; 28 | std::cout << std::boolalpha << ptrOne.unique() << std::endl; 29 | 30 | ptrThree->Print(); 31 | 32 | ptrOne.reset(); 33 | std::cout << "one" << std::endl; 34 | ptrTwo.reset(); 35 | std::cout << "two" << std::endl; 36 | ptrThree.reset(); 37 | std::cout << "three" << std::endl; 38 | 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /cpp17/lectures/03_smart_pointers/sources/04.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | struct Object 5 | { 6 | ~Object() 7 | { 8 | std::cout << "~Object" << std::endl; 9 | } 10 | void Print() const 11 | { 12 | std::cout << "some message" << std::endl; 13 | } 14 | }; 15 | 16 | int main() 17 | { 18 | auto ptrOne = std::make_shared(); 19 | std::cout << ptrOne.use_count() << std::endl; 20 | 21 | auto ptrTwo = ptrOne; 22 | std::cout << ptrOne.use_count() << std::endl; 23 | 24 | std::weak_ptr weakPtr = ptrOne; 25 | std::cout << ptrOne.use_count() << std::endl; 26 | 27 | auto ptrThree = weakPtr.lock(); 28 | std::cout << ptrOne.use_count() << std::endl; 29 | 30 | ptrOne.reset(); 31 | ptrTwo.reset(); 32 | ptrThree.reset(); 33 | 34 | std::cout << std::boolalpha << weakPtr.expired() << std::endl; 35 | auto ptrFour = weakPtr.lock(); 36 | std::cout << std::boolalpha << static_cast(ptrFour) << std::endl; 37 | 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /cpp17/lectures/04_multithreading/multithreading.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp17/lectures/04_multithreading/multithreading.pdf -------------------------------------------------------------------------------- /cpp17/lectures/04_multithreading/sources/01.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | //1. simple thread 6 | //2. exception in thread 7 | //3. callable item 8 | //4. join or detach 9 | //5. arguments 10 | 11 | 12 | struct callableObject 13 | { 14 | void operator()() const 15 | { 16 | std::cout << std::this_thread::get_id() << std::endl; 17 | } 18 | }; 19 | 20 | int main() 21 | { 22 | std::cout << std::this_thread::get_id() << std::endl; 23 | std::thread([](){ 24 | std::cout << std::this_thread::get_id() << std::endl; 25 | }).join(); 26 | 27 | std::thread(callableObject{}).join(); 28 | std::thread(callableObject{}).join(); 29 | return 0; 30 | } -------------------------------------------------------------------------------- /cpp17/lectures/04_multithreading/sources/02.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | std::thread([](){ 7 | for (int i = 0; i < 10; i++) 8 | { 9 | std::cout << std::this_thread::get_id() << ":" << i << std::endl; 10 | } 11 | }).detach(); 12 | 13 | std::thread([](){ 14 | for (int i = 0; i < 10; i++) 15 | { 16 | std::cout << std::this_thread::get_id() << ":" << i << std::endl; 17 | } 18 | }).detach(); 19 | 20 | std::thread([](){ 21 | for (int i = 0; i < 10; i++) 22 | { 23 | std::cout << std::this_thread::get_id() << ":" << i << std::endl; 24 | } 25 | }).detach(); 26 | 27 | std::thread([](){ 28 | for (int i = 0; i < 10; i++) 29 | { 30 | std::cout << std::this_thread::get_id() << ":" << i << std::endl; 31 | } 32 | }).join(); 33 | return 0; 34 | } -------------------------------------------------------------------------------- /cpp17/lectures/04_multithreading/sources/03.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void foo(std::string & s) 5 | { 6 | s += s; 7 | } 8 | 9 | int main() 10 | { 11 | std::string s = "foo"; 12 | std::thread(foo, s).join(); 13 | std::cout << s.c_str() << std::endl; 14 | 15 | std::thread(foo, std::ref(s)).join(); 16 | std::cout << s.c_str() << std::endl; 17 | return 0; 18 | } -------------------------------------------------------------------------------- /cpp17/lectures/04_multithreading/sources/03a.cpp: -------------------------------------------------------------------------------- 1 | //#include 2 | //#include 3 | //#include 4 | //#include 5 | // 6 | //// future & async simple sample 7 | // 8 | //int getting_data() 9 | //{ 10 | // std::this_thread::sleep_for(std::chrono::seconds(3)); 11 | // return 42; 12 | //} 13 | // 14 | //void print_future(std::shared_future f) 15 | //{ 16 | // std::this_thread::sleep_for(std::chrono::milliseconds(500)); 17 | // std::cout << f.get() << std::endl; 18 | //} 19 | // 20 | //void tick() 21 | //{ 22 | // int i = 4; 23 | // while (i) 24 | // { 25 | // std::cout << "."; 26 | // i--; 27 | // std::this_thread::sleep_for(std::chrono::milliseconds(1000)); 28 | // } 29 | //} 30 | // 31 | //int main() 32 | //{ 33 | // std::thread t1(tick); // tick 1s 34 | // auto sf = std::async(std::launch::async, getting_data).share(); 35 | // 36 | // std::thread t2(print_future, sf); 37 | // std::thread t3(print_future, sf); 38 | // std::thread t4(print_future, sf); 39 | // 40 | // t1.join(); 41 | // t2.join(); 42 | // t3.join(); 43 | // t4.join(); 44 | // return 0; 45 | //} -------------------------------------------------------------------------------- /cpp17/lectures/04_multithreading/sources/04.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | struct Object 6 | { 7 | std::string name; 8 | void print() const 9 | { 10 | std::cout << name << std::endl; 11 | } 12 | 13 | void printMessage(const std::string & message) const 14 | { 15 | std::cout << name << ":" << message << std::endl; 16 | } 17 | 18 | void getName(std::string & message) const 19 | { 20 | std::cout << "name = " << name << std::endl; 21 | message = name; 22 | } 23 | 24 | void change() 25 | { 26 | name += name; 27 | } 28 | }; 29 | 30 | int main() 31 | { 32 | Object o; 33 | o.name = "student"; 34 | 35 | std::thread(&Object::print, o).join(); 36 | 37 | std::string message = "some message"; 38 | std::thread(&Object::printMessage, o, message).join(); 39 | 40 | std::thread(&Object::getName, o, message).join(); 41 | std::cout << message << std::endl; 42 | 43 | std::thread(&Object::getName, o, std::ref(message)).join(); 44 | std::cout << message << std::endl; 45 | 46 | std::thread(&Object::change, o).join(); 47 | std::cout << o.name << std::endl; 48 | 49 | std::thread(&Object::change, std::ref(o)).join(); 50 | std::cout << o.name << std::endl; 51 | 52 | return 0; 53 | } -------------------------------------------------------------------------------- /cpp17/lectures/04_multithreading/sources/05.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | std::thread t([](){ 7 | std::cout << std::this_thread::get_id() << std::endl; 8 | }); 9 | 10 | t.detach(); 11 | try 12 | { 13 | t.join(); 14 | } 15 | catch (...) 16 | { 17 | std::cout << "opan'ki" << std::endl; 18 | } 19 | 20 | std::thread t2([](){ 21 | std::cout << std::this_thread::get_id() << std::endl; 22 | }); 23 | 24 | std::this_thread::sleep_for(std::chrono::milliseconds(1000)); 25 | 26 | t2.detach(); 27 | if (t2.joinable()) 28 | t.join(); 29 | 30 | return 0; 31 | } -------------------------------------------------------------------------------- /cpp17/lectures/04_multithreading/sources/06.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void thread_function() 5 | { 6 | std::cout << "thread function\n"; 7 | } 8 | 9 | int main() 10 | { 11 | std::thread t(&thread_function); 12 | 13 | // std::thread t2 = t; // Copying a thread won't compile: 14 | std::thread t2 = std::move(t); // from now t.joinable() returns false 15 | 16 | std::cout << std::boolalpha << t.joinable() << std::endl; 17 | std::cout << std::boolalpha << t2.joinable() << std::endl; 18 | 19 | t2.join(); 20 | 21 | std::cout << std::boolalpha << t.joinable() << std::endl; 22 | std::cout << std::boolalpha << t2.joinable() << std::endl; 23 | 24 | 25 | std::cout << std::endl << std::endl << "creating 2 threads" << std::endl; 26 | t = std::thread(&thread_function); 27 | t2 = std::thread(&thread_function); 28 | 29 | std::cout << std::boolalpha << t.joinable() << std::endl; 30 | std::cout << std::boolalpha << t2.joinable() << std::endl; 31 | t2 = std::move(t); // calling std::terminate() 32 | 33 | return 0; 34 | } -------------------------------------------------------------------------------- /cpp17/lectures/04_multithreading/sources/07.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | void thread_function() 7 | { 8 | std::cout << std::this_thread::get_id() << std::endl; 9 | } 10 | 11 | int main() 12 | { 13 | std::vector v; 14 | 15 | for (int u = 0; u < 20; u++) 16 | { 17 | v.push_back(std::thread(thread_function)); 18 | } 19 | std::for_each(v.begin(), v.end(), std::mem_fn(&std::thread::join)); 20 | 21 | return 0; 22 | } -------------------------------------------------------------------------------- /cpp17/lectures/04_multithreading/sources/08.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | // future & async simple sample 7 | 8 | 9 | int getting_data() 10 | { 11 | std::this_thread::sleep_for(std::chrono::milliseconds(10000)); 12 | return 42; 13 | } 14 | 15 | int getting_data_quick(int i) 16 | { 17 | return i * i; 18 | } 19 | 20 | void tick() 21 | { 22 | int i = 10; 23 | while (i) 24 | { 25 | std::cout << "."; 26 | i--; 27 | std::this_thread::sleep_for(std::chrono::milliseconds(1000)); 28 | } 29 | } 30 | 31 | int main() 32 | { 33 | std::thread t1(tick); // tick 1s 34 | std::future f = std::async(std::launch::async, getting_data); // launching a long time operation 35 | // std::future f = std::async(std::launch::deferred, getting_data); // deferred launching a long time operation 36 | // std::future f = std::async(std::launch::async, getting_data_quick, 10); // launching a quick time operation 37 | 38 | std::cout << std::boolalpha << f.valid() << std::endl; 39 | 40 | std::this_thread::sleep_for(std::chrono::milliseconds(5000)); // performs other actions 41 | 42 | auto i = f.get(); // getting result 43 | std::cout << i << std::endl; 44 | std::cout << std::boolalpha << f.valid() << std::endl; 45 | 46 | t1.join(); 47 | return 0; 48 | } -------------------------------------------------------------------------------- /cpp17/lectures/04_multithreading/sources/08a.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | // future & async simple sample 7 | 8 | int getting_data() 9 | { 10 | std::this_thread::sleep_for(std::chrono::seconds(3)); 11 | return 42; 12 | } 13 | 14 | void print_future(std::shared_future f) 15 | { 16 | std::this_thread::sleep_for(std::chrono::milliseconds(500)); 17 | std::cout << f.get() << std::endl; 18 | } 19 | 20 | void tick() 21 | { 22 | int i = 4; 23 | while (i) 24 | { 25 | std::cout << "."; 26 | i--; 27 | std::this_thread::sleep_for(std::chrono::milliseconds(1000)); 28 | } 29 | } 30 | 31 | int main() 32 | { 33 | std::thread t1(tick); // tick 1s 34 | auto sf = std::async(std::launch::async, getting_data).share(); 35 | 36 | std::thread t2(print_future, sf); 37 | std::thread t3(print_future, sf); 38 | std::thread t4(print_future, sf); 39 | 40 | t1.join(); 41 | t2.join(); 42 | t3.join(); 43 | t4.join(); 44 | return 0; 45 | } -------------------------------------------------------------------------------- /cpp17/lectures/04_multithreading/sources/09.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | // catch exception from thread 7 | 8 | 9 | int getting_data() 10 | { 11 | std::this_thread::sleep_for(std::chrono::milliseconds(3000)); 12 | 13 | throw 42; 14 | return 42; 15 | } 16 | 17 | void tick() 18 | { 19 | int i = 10; 20 | while (i) 21 | { 22 | std::cout << "."; 23 | i--; 24 | std::this_thread::sleep_for(std::chrono::seconds(1)); 25 | } 26 | } 27 | 28 | int main() 29 | { 30 | std::thread t1(tick); // tick 1s 31 | std::future f = std::async(std::launch::async, getting_data); 32 | 33 | try 34 | { 35 | auto i = f.get(); // getting result 36 | std::cout << i << std::endl; 37 | } 38 | catch (int i) 39 | { 40 | std::cout << "catch " << i << std::endl; 41 | } 42 | 43 | t1.join(); 44 | return 0; 45 | } -------------------------------------------------------------------------------- /cpp17/lectures/04_multithreading/sources/10.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #if _MSC_VER <= 1800 5 | // VS 2013 doesn't support thread_local keyword 6 | #define thread_local __declspec(thread) 7 | #endif 8 | 9 | static thread_local unsigned int thread_var = 0; 10 | static unsigned int global_var = 0; 11 | 12 | void foo_thread() 13 | { 14 | for (int i = 0; i < 10; i++) 15 | { 16 | std::cout << std::this_thread::get_id() << ":" << thread_var++ << std::endl; 17 | std::this_thread::sleep_for(std::chrono::milliseconds(100)); 18 | } 19 | } 20 | 21 | 22 | void foo_global() 23 | { 24 | for (int i = 0; i < 10; i++) 25 | { 26 | std::cout << std::this_thread::get_id() << ":" << global_var++ << std::endl; 27 | std::this_thread::sleep_for(std::chrono::milliseconds(100)); 28 | } 29 | } 30 | 31 | 32 | int main() 33 | { 34 | 35 | std::thread(foo_global).detach(); 36 | std::thread(foo_global).detach(); 37 | std::thread(foo_global).detach(); 38 | std::thread(foo_global).detach(); 39 | std::thread(foo_global).join(); 40 | std::cout << "GLOBAL = " << global_var << std::endl; 41 | std::cout << "----------------------------" << std::endl; 42 | 43 | 44 | std::thread(foo_thread).detach(); 45 | std::thread(foo_thread).detach(); 46 | std::thread(foo_thread).detach(); 47 | std::thread(foo_thread).detach(); 48 | std::thread(foo_thread).join(); 49 | std::cout << "THREAD = " << thread_var << std::endl; 50 | 51 | return 0; 52 | } -------------------------------------------------------------------------------- /cpp17/lectures/05_synchronization/sources/01.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | template 7 | class SafeQueue 8 | { 9 | public: 10 | void Push(const T& data) 11 | { 12 | std::lock_guard lk(Mutex); 13 | Queue.push(data); 14 | } 15 | 16 | T Pop() 17 | { 18 | std::lock_guard lk(Mutex); 19 | T data = Queue.front(); 20 | Queue.pop(); 21 | return data; 22 | } 23 | 24 | private: 25 | std::queue Queue; 26 | std::mutex Mutex; 27 | }; 28 | 29 | SafeQueue queue; 30 | 31 | void foo() 32 | { 33 | for (int i = 0; i < 10; ++i) 34 | { 35 | queue.Push(i); 36 | std::this_thread::sleep_for(std::chrono::microseconds(10)); 37 | } 38 | } 39 | 40 | int main() 41 | { 42 | std::thread t1(foo); 43 | std::thread t2(foo); 44 | 45 | t1.join(); 46 | t2.join(); 47 | 48 | for (int i = 0; i < 20; ++i) 49 | { 50 | std::cout << queue.Pop() << std::endl; 51 | } 52 | 53 | return 0; 54 | } -------------------------------------------------------------------------------- /cpp17/lectures/05_synchronization/sources/02.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | // cv simple sample 6 | 7 | std::mutex m; 8 | bool flag = false; 9 | std::condition_variable cv; 10 | 11 | void waiting_cv() 12 | { 13 | std::unique_lock lk(m); 14 | 15 | cv.wait(lk, [](){ 16 | std::cout << ".."; 17 | return flag; 18 | }); 19 | 20 | // using flag 21 | std::cout << std::endl << std::boolalpha << flag; 22 | } 23 | 24 | void process() 25 | { 26 | std::lock_guard lk(m); 27 | std::this_thread::sleep_for(std::chrono::milliseconds(500)); // some action 28 | flag = true; 29 | cv.notify_one(); // data is ready 30 | } 31 | 32 | int main() 33 | { 34 | std::thread t1(waiting_cv); 35 | std::thread t2(process); 36 | 37 | t1.join(); 38 | t2.join(); 39 | 40 | return 0; 41 | } -------------------------------------------------------------------------------- /cpp17/lectures/05_synchronization/sources/03.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | // cv simple sample. testing queue 7 | 8 | std::mutex m; 9 | std::queue q; 10 | std::condition_variable cv; 11 | 12 | void waiting_cv() 13 | { 14 | int r = -1; 15 | while (r != 9) 16 | { 17 | std::unique_lock lk(m); 18 | cv.wait(lk, [](){ 19 | std::cout << ".."; 20 | return !q.empty(); 21 | }); // wait while q.empty() 22 | 23 | // lk is already locked 24 | // we can using queue 25 | r = q.front(); 26 | q.pop(); 27 | lk.unlock(); 28 | 29 | std::cout << std::endl << std::boolalpha << r; 30 | std::this_thread::sleep_for(std::chrono::milliseconds(100)); // some action 31 | } 32 | } 33 | 34 | void waiting_for_cv() 35 | { 36 | int r = -1; 37 | while (r != 9) 38 | { 39 | std::unique_lock lk(m); 40 | 41 | // wait for 100 milliseconds 42 | auto pred_result = cv.wait_for(lk, 43 | std::chrono::milliseconds(100), 44 | [](){ 45 | std::cout << ".."; 46 | return !q.empty(); 47 | }); 48 | 49 | if (!pred_result) // if q.empty() continue; else we can using queue 50 | continue; 51 | 52 | // lk is already locked 53 | // we can using queue 54 | r = q.front(); 55 | q.pop(); 56 | lk.unlock(); 57 | 58 | std::cout << std::endl << std::boolalpha << r; 59 | std::this_thread::sleep_for(std::chrono::milliseconds(100)); // some action 60 | } 61 | } 62 | 63 | void process() 64 | { 65 | int i = 0; 66 | while (i < 10) 67 | { 68 | std::this_thread::sleep_for(std::chrono::milliseconds(500)); // some action 69 | std::lock_guard lk(m); // lock 70 | q.push(i++); // push data 71 | cv.notify_one(); // data is ready 72 | } 73 | } 74 | 75 | int main() 76 | { 77 | std::thread t1(waiting_cv); 78 | std::thread t2(process); 79 | 80 | t1.join(); 81 | t2.join(); 82 | 83 | return 0; 84 | } -------------------------------------------------------------------------------- /cpp17/lectures/05_synchronization/sources/04.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | // cv simple sample. testing queue 7 | 8 | std::mutex m; 9 | std::queue q; 10 | std::condition_variable cv; 11 | 12 | void consumer() 13 | { 14 | int r = -1; 15 | while (r != 9) 16 | { 17 | std::unique_lock lk(m); 18 | cv.wait(lk, [](){ 19 | std::cout << ".."; 20 | return !q.empty(); 21 | }); // wait while q.empty() 22 | 23 | // lk is already locked 24 | // we can using queue 25 | r = q.front(); 26 | q.pop(); 27 | lk.unlock(); 28 | 29 | std::cout << std::endl << std::boolalpha << r; 30 | std::this_thread::sleep_for(std::chrono::microseconds(100)); // some action 31 | } 32 | } 33 | 34 | void producer() 35 | { 36 | int i = 0; 37 | while (i < 10) 38 | { 39 | std::this_thread::sleep_for(std::chrono::milliseconds(500)); // some action 40 | std::lock_guard lk(m); // lock 41 | q.push(i++); // push data 42 | cv.notify_one(); // data is ready 43 | } 44 | } 45 | 46 | int main() 47 | { 48 | std::thread t1(consumer); 49 | std::thread t2(producer); 50 | std::thread t3(producer); 51 | 52 | t1.join(); 53 | t2.join(); 54 | t3.join(); 55 | 56 | return 0; 57 | } -------------------------------------------------------------------------------- /cpp17/lectures/05_synchronization/sources/05.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | // Demonstrate data race 10 | 11 | uint64_t g_sum = 0; 12 | std::atomic g_a_sum = 0; 13 | 14 | void summ(unsigned long long a, unsigned long long b) 15 | { 16 | for (unsigned long long i = a; i < b; i++) 17 | { 18 | g_sum = g_sum + i; 19 | } 20 | } 21 | 22 | void atomic_summ(unsigned long long a, unsigned long long b) 23 | { 24 | for (unsigned long long i = a; i < b; i++) 25 | { 26 | g_a_sum += i; // or fetch_add 27 | // g_a_sum.fetch_add(i); 28 | } 29 | } 30 | 31 | int main() 32 | { 33 | const unsigned long long n = 10000000; 34 | 35 | std::thread t1(summ, 0, n); 36 | std::thread t2(summ, n, 2 * n); 37 | std::thread t3(summ, 2 * n, 3 * n); 38 | std::thread t4(summ, 3 * n, (4 * n) + 1); 39 | 40 | std::thread t1_a(atomic_summ, 0, n); 41 | std::thread t2_a(atomic_summ, n, 2 * n); 42 | std::thread t3_a(atomic_summ, 2 * n, 3 * n); 43 | std::thread t4_a(atomic_summ, 3 * n, (4 * n) + 1); 44 | 45 | t1_a.join(); 46 | t2_a.join(); 47 | t3_a.join(); 48 | t4_a.join(); 49 | 50 | t1.join(); 51 | t2.join(); 52 | t3.join(); 53 | t4.join(); 54 | 55 | std::cout << "summ = " << g_sum << std::endl; 56 | std::cout << "summ = " << g_a_sum << std::endl; 57 | std::cout << "answer = " << (n * 4) * (4 * n + 1) / 2 << std::endl; 58 | 59 | return 0; 60 | } -------------------------------------------------------------------------------- /cpp17/lectures/05_synchronization/synchronization.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp17/lectures/05_synchronization/synchronization.pdf -------------------------------------------------------------------------------- /cpp17/lectures/05_thread_pool/sources/main.cpp: -------------------------------------------------------------------------------- 1 | #include "thread_pool.h" 2 | 3 | #include 4 | 5 | void foo(int time) 6 | { 7 | std::cout << "begin on " << std::this_thread::get_id() << std::endl; 8 | std::this_thread::sleep_for(std::chrono::seconds(time)); 9 | std::cout << "end on " << std::this_thread::get_id() << std::endl; 10 | } 11 | 12 | int bar(int time) 13 | { 14 | std::cout << "returns " << time << " on " << std::this_thread::get_id() << std::endl; 15 | return time; 16 | } 17 | 18 | int main() 19 | { 20 | thread_pool pool(8); 21 | 22 | pool.submit(foo, 10); 23 | pool.submit(foo, 10); 24 | pool.submit(foo, 10); 25 | pool.submit(foo, 10); 26 | auto f = pool.submit([](int time) 27 | { 28 | std::cout << "returns " << time << " on " << std::this_thread::get_id() << std::endl; 29 | return time; 30 | }, 10); 31 | pool.submit(bar, 10).get(); 32 | 33 | 34 | std::cout << f.get(); 35 | std::this_thread::sleep_for(std::chrono::seconds(2)); 36 | } -------------------------------------------------------------------------------- /cpp17/lectures/05_thread_pool/sources/thread_pool.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | 8 | class thread_pool 9 | { 10 | public: 11 | 12 | thread_pool() 13 | { 14 | _start(); 15 | } 16 | 17 | thread_pool(size_t num) : 18 | _num(num) 19 | { 20 | _start(); 21 | } 22 | 23 | ~thread_pool() 24 | { 25 | std::unique_lock lk(_m); 26 | _stop = true; 27 | lk.unlock(); 28 | 29 | cv.notify_all(); 30 | for (auto & t : _threads) 31 | t.join(); 32 | } 33 | 34 | template 35 | std::future> submit(F && func, Args && ... args) 36 | { 37 | using result_type = std::result_of_t; 38 | 39 | auto ptr_task = std::make_shared>( 40 | std::bind(std::forward(func), std::forward(args)... )); 41 | 42 | auto result = ptr_task->get_future(); 43 | 44 | std::lock_guard lk(_m); 45 | _tasks.emplace([ptr_task]() -> void 46 | { 47 | (*ptr_task)(); 48 | }); 49 | 50 | cv.notify_one(); 51 | return result; 52 | } 53 | 54 | private: 55 | size_t _num = std::thread::hardware_concurrency(); 56 | std::queue> _tasks; 57 | std::vector _threads; 58 | std::mutex _m; 59 | std::condition_variable cv; 60 | bool _stop; 61 | 62 | void _working_thread_func() 63 | { 64 | while (true) 65 | { 66 | std::unique_lock lk(_m); 67 | cv.wait(lk, [this]() 68 | { 69 | return _stop || !this->_tasks.empty(); 70 | }); 71 | 72 | if (_stop) 73 | return; 74 | 75 | auto task = _tasks.front(); 76 | _tasks.pop(); 77 | lk.unlock(); 78 | 79 | task(); 80 | } 81 | } 82 | 83 | void _start() 84 | { 85 | _stop = false; 86 | for (size_t i = 0; i < _num; i++) 87 | _threads.push_back(std::thread(&thread_pool::_working_thread_func, this)); 88 | } 89 | }; 90 | -------------------------------------------------------------------------------- /cpp17/lectures/05_thread_pool/thread_pool.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp17/lectures/05_thread_pool/thread_pool.pdf -------------------------------------------------------------------------------- /cpp17/lectures/06_networks/networks.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp17/lectures/06_networks/networks.pdf -------------------------------------------------------------------------------- /cpp17/lectures/06_networks/sources/client.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using boost::asio::ip::tcp; 6 | 7 | int main(int argc, char* argv[]) 8 | { 9 | try 10 | { 11 | boost::asio::io_service io_service; 12 | 13 | tcp::endpoint ep(boost::asio::ip::address::from_string("127.0.0.1"), 8000); 14 | 15 | tcp::socket socket(io_service, ep.protocol()); 16 | socket.connect(ep); 17 | 18 | boost::array buf; 19 | boost::system::error_code error; 20 | 21 | socket.write_some(boost::asio::buffer("Boost.Asio client")); 22 | 23 | int len = 0; 24 | while(len = socket.read_some(boost::asio::buffer(buf), error)) 25 | { 26 | if (error == boost::asio::error::eof) 27 | break; 28 | else if (error) 29 | throw boost::system::system_error(error); 30 | 31 | std::cout.write(buf.data(), len); 32 | } 33 | } 34 | catch (std::exception& e) 35 | { 36 | std::cerr << e.what() << std::endl; 37 | } 38 | 39 | return 0; 40 | } -------------------------------------------------------------------------------- /cpp17/lectures/06_networks/sources/server.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp17/lectures/06_networks/sources/server.cpp -------------------------------------------------------------------------------- /cpp17/lectures/06_networks/sources/server_asio.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp17/lectures/06_networks/sources/server_asio.cpp -------------------------------------------------------------------------------- /cpp17/lectures/06_networks/sources/server_refactoring.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp17/lectures/06_networks/sources/server_refactoring.cpp -------------------------------------------------------------------------------- /cpp17/lectures/07_memory_management/memory_management.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp17/lectures/07_memory_management/memory_management.pdf -------------------------------------------------------------------------------- /cpp18/lectures/01_introduction/introduction.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp18/lectures/01_introduction/introduction.pdf -------------------------------------------------------------------------------- /cpp18/lectures/02_smart_pointers/smart_pointers.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp18/lectures/02_smart_pointers/smart_pointers.pdf -------------------------------------------------------------------------------- /cpp18/lectures/03_move_semantics/code/lec/benchmark.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | int main() { 10 | const int N = 1 << 23; 11 | const int K = 25; 12 | 13 | for (int k = 0; k < K; ++k) { 14 | // copy benchmark 15 | { 16 | std::vector vec(N); 17 | auto startTime = std::chrono::high_resolution_clock::now(); 18 | srand(1); 19 | for (int i = 0; i < N; ++i) { 20 | std::string s = std::to_string(rand()); 21 | vec[i] = s; 22 | s.clear(); 23 | } 24 | auto endTime = std::chrono::high_resolution_clock::now(); 25 | auto diff = std::chrono::duration_cast( 26 | endTime - startTime) 27 | .count(); 28 | std::cout << "copy - " << diff << std::endl; 29 | } 30 | 31 | // move benchmark 32 | { 33 | std::vector vec(N); 34 | auto startTime = std::chrono::high_resolution_clock::now(); 35 | srand(1); 36 | for (int i = 0; i < N; ++i) { 37 | std::string s = std::to_string(rand()); 38 | vec[i] = std::move(s); 39 | s.clear(); 40 | } 41 | auto endTime = std::chrono::high_resolution_clock::now(); 42 | auto diff = std::chrono::duration_cast( 43 | endTime - startTime) 44 | .count(); 45 | std::cout << "move - " << diff << std::endl; 46 | } 47 | } 48 | system("pause"); 49 | 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /cpp18/lectures/03_move_semantics/code/lec/by_value.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | std::string get_engine_model_from_file() 4 | { 5 | return "id134"; 6 | } 7 | 8 | struct Engine 9 | { 10 | Engine(std::string model) : model_(std::move(model)) { } 11 | 12 | private: 13 | std::string model_; 14 | }; 15 | 16 | struct Car 17 | { 18 | Car(std::string engine_model) : engine_(std::move(engine_model)) { } 19 | 20 | private: 21 | Engine engine_; 22 | }; 23 | 24 | int main() 25 | { 26 | Car car(get_engine_model_from_file()); // here call move ctor of std::string 27 | 28 | std::string model = "new awesome engine"; 29 | Car new_car(model); // here call copy ctor of std::string 30 | } -------------------------------------------------------------------------------- /cpp18/lectures/03_move_semantics/code/lec/lec.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lec", "lec.vcxproj", "{29DD0DD3-9E77-4369-8B13-8D8EEAE3DE7B}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {29DD0DD3-9E77-4369-8B13-8D8EEAE3DE7B}.Debug|x64.ActiveCfg = Debug|x64 17 | {29DD0DD3-9E77-4369-8B13-8D8EEAE3DE7B}.Debug|x64.Build.0 = Debug|x64 18 | {29DD0DD3-9E77-4369-8B13-8D8EEAE3DE7B}.Debug|x86.ActiveCfg = Debug|Win32 19 | {29DD0DD3-9E77-4369-8B13-8D8EEAE3DE7B}.Debug|x86.Build.0 = Debug|Win32 20 | {29DD0DD3-9E77-4369-8B13-8D8EEAE3DE7B}.Release|x64.ActiveCfg = Release|x64 21 | {29DD0DD3-9E77-4369-8B13-8D8EEAE3DE7B}.Release|x64.Build.0 = Release|x64 22 | {29DD0DD3-9E77-4369-8B13-8D8EEAE3DE7B}.Release|x86.ActiveCfg = Release|Win32 23 | {29DD0DD3-9E77-4369-8B13-8D8EEAE3DE7B}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /cpp18/lectures/03_move_semantics/code/lec/move_and_forward.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | struct Engine { 4 | Engine(const std::string& model) : model_(model) {} 5 | Engine(std::string&& model) : model_(std::move(model)) {} 6 | 7 | private: 8 | std::string model_; 9 | }; 10 | 11 | struct Car { 12 | Car(const std::string& engine_model) : engine_(engine_model) {} 13 | Car(std::string&& engine_model) : engine_(std::move(engine_model)) {} 14 | 15 | private: 16 | Engine engine_; 17 | }; 18 | 19 | std::string get_engine_model_from_file() { 20 | return "id134"; 21 | } 22 | 23 | int main() { 24 | Car car(get_engine_model_from_file()); 25 | 26 | std::string model = "new awesome engine"; 27 | Car new_car(model); // here call copy ctor of std::string 28 | } -------------------------------------------------------------------------------- /cpp18/lectures/03_move_semantics/move_semantics.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp18/lectures/03_move_semantics/move_semantics.pdf -------------------------------------------------------------------------------- /cpp18/lectures/04_multithreads/multithreading.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp18/lectures/04_multithreads/multithreading.pdf -------------------------------------------------------------------------------- /cpp18/lectures/04_multithreads/sources/01.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | //1. simple thread 6 | //2. exception in thread 7 | //3. callable item 8 | //4. join or detach 9 | //5. arguments 10 | 11 | 12 | struct callableObject 13 | { 14 | void operator()() const 15 | { 16 | std::cout << std::this_thread::get_id() << std::endl; 17 | } 18 | }; 19 | 20 | int main() 21 | { 22 | std::cout << std::this_thread::get_id() << std::endl; 23 | std::thread([](){ 24 | std::cout << std::this_thread::get_id() << std::endl; 25 | }).join(); 26 | 27 | std::thread(callableObject{}).join(); 28 | std::thread(callableObject{}).join(); 29 | return 0; 30 | } -------------------------------------------------------------------------------- /cpp18/lectures/04_multithreads/sources/02.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | std::thread([](){ 7 | for (int i = 0; i < 10; i++) 8 | { 9 | std::cout << std::this_thread::get_id() << ":" << i << std::endl; 10 | } 11 | }).detach(); 12 | 13 | std::thread([](){ 14 | for (int i = 0; i < 10; i++) 15 | { 16 | std::cout << std::this_thread::get_id() << ":" << i << std::endl; 17 | } 18 | }).detach(); 19 | 20 | std::thread([](){ 21 | for (int i = 0; i < 10; i++) 22 | { 23 | std::cout << std::this_thread::get_id() << ":" << i << std::endl; 24 | } 25 | }).detach(); 26 | 27 | std::thread([](){ 28 | for (int i = 0; i < 10; i++) 29 | { 30 | std::cout << std::this_thread::get_id() << ":" << i << std::endl; 31 | } 32 | }).join(); 33 | return 0; 34 | } -------------------------------------------------------------------------------- /cpp18/lectures/04_multithreads/sources/03.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void foo(std::string & s) 5 | { 6 | s += s; 7 | } 8 | 9 | int main() 10 | { 11 | std::string s = "foo"; 12 | std::thread(foo, s).join(); 13 | std::cout << s.c_str() << std::endl; 14 | 15 | std::thread(foo, std::ref(s)).join(); 16 | std::cout << s.c_str() << std::endl; 17 | return 0; 18 | } -------------------------------------------------------------------------------- /cpp18/lectures/04_multithreads/sources/03a.cpp: -------------------------------------------------------------------------------- 1 | //#include 2 | //#include 3 | //#include 4 | //#include 5 | // 6 | //// future & async simple sample 7 | // 8 | //int getting_data() 9 | //{ 10 | // std::this_thread::sleep_for(std::chrono::seconds(3)); 11 | // return 42; 12 | //} 13 | // 14 | //void print_future(std::shared_future f) 15 | //{ 16 | // std::this_thread::sleep_for(std::chrono::milliseconds(500)); 17 | // std::cout << f.get() << std::endl; 18 | //} 19 | // 20 | //void tick() 21 | //{ 22 | // int i = 4; 23 | // while (i) 24 | // { 25 | // std::cout << "."; 26 | // i--; 27 | // std::this_thread::sleep_for(std::chrono::milliseconds(1000)); 28 | // } 29 | //} 30 | // 31 | //int main() 32 | //{ 33 | // std::thread t1(tick); // tick 1s 34 | // auto sf = std::async(std::launch::async, getting_data).share(); 35 | // 36 | // std::thread t2(print_future, sf); 37 | // std::thread t3(print_future, sf); 38 | // std::thread t4(print_future, sf); 39 | // 40 | // t1.join(); 41 | // t2.join(); 42 | // t3.join(); 43 | // t4.join(); 44 | // return 0; 45 | //} -------------------------------------------------------------------------------- /cpp18/lectures/04_multithreads/sources/04.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | struct Object 6 | { 7 | std::string name; 8 | void print() const 9 | { 10 | std::cout << name << std::endl; 11 | } 12 | 13 | void printMessage(const std::string & message) const 14 | { 15 | std::cout << name << ":" << message << std::endl; 16 | } 17 | 18 | void getName(std::string & message) const 19 | { 20 | std::cout << "name = " << name << std::endl; 21 | message = name; 22 | } 23 | 24 | void change() 25 | { 26 | name += name; 27 | } 28 | }; 29 | 30 | int main() 31 | { 32 | Object o; 33 | o.name = "student"; 34 | 35 | std::thread(&Object::print, o).join(); 36 | 37 | std::string message = "some message"; 38 | std::thread(&Object::printMessage, o, message).join(); 39 | 40 | std::thread(&Object::getName, o, message).join(); 41 | std::cout << message << std::endl; 42 | 43 | std::thread(&Object::getName, o, std::ref(message)).join(); 44 | std::cout << message << std::endl; 45 | 46 | std::thread(&Object::change, o).join(); 47 | std::cout << o.name << std::endl; 48 | 49 | std::thread(&Object::change, std::ref(o)).join(); 50 | std::cout << o.name << std::endl; 51 | 52 | return 0; 53 | } -------------------------------------------------------------------------------- /cpp18/lectures/04_multithreads/sources/05.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | std::thread t([](){ 7 | std::cout << std::this_thread::get_id() << std::endl; 8 | }); 9 | 10 | t.detach(); 11 | try 12 | { 13 | t.join(); 14 | } 15 | catch (...) 16 | { 17 | std::cout << "opan'ki" << std::endl; 18 | } 19 | 20 | std::thread t2([](){ 21 | std::cout << std::this_thread::get_id() << std::endl; 22 | }); 23 | 24 | std::this_thread::sleep_for(std::chrono::milliseconds(1000)); 25 | 26 | t2.detach(); 27 | if (t2.joinable()) 28 | t.join(); 29 | 30 | return 0; 31 | } -------------------------------------------------------------------------------- /cpp18/lectures/04_multithreads/sources/06.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void thread_function() 5 | { 6 | std::cout << "thread function\n"; 7 | } 8 | 9 | int main() 10 | { 11 | std::thread t(&thread_function); 12 | 13 | // std::thread t2 = t; // Copying a thread won't compile: 14 | std::thread t2 = std::move(t); // from now t.joinable() returns false 15 | 16 | std::cout << std::boolalpha << t.joinable() << std::endl; 17 | std::cout << std::boolalpha << t2.joinable() << std::endl; 18 | 19 | t2.join(); 20 | 21 | std::cout << std::boolalpha << t.joinable() << std::endl; 22 | std::cout << std::boolalpha << t2.joinable() << std::endl; 23 | 24 | 25 | std::cout << std::endl << std::endl << "creating 2 threads" << std::endl; 26 | t = std::thread(&thread_function); 27 | t2 = std::thread(&thread_function); 28 | 29 | std::cout << std::boolalpha << t.joinable() << std::endl; 30 | std::cout << std::boolalpha << t2.joinable() << std::endl; 31 | t2 = std::move(t); // calling std::terminate() 32 | 33 | return 0; 34 | } -------------------------------------------------------------------------------- /cpp18/lectures/04_multithreads/sources/07.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | void thread_function() 7 | { 8 | std::cout << std::this_thread::get_id() << std::endl; 9 | } 10 | 11 | int main() 12 | { 13 | std::vector v; 14 | 15 | for (int u = 0; u < 20; u++) 16 | { 17 | v.push_back(std::thread(thread_function)); 18 | } 19 | std::for_each(v.begin(), v.end(), std::mem_fn(&std::thread::join)); 20 | 21 | return 0; 22 | } -------------------------------------------------------------------------------- /cpp18/lectures/04_multithreads/sources/08.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | // future & async simple sample 7 | 8 | 9 | int getting_data() 10 | { 11 | std::this_thread::sleep_for(std::chrono::milliseconds(10000)); 12 | return 42; 13 | } 14 | 15 | int getting_data_quick(int i) 16 | { 17 | return i * i; 18 | } 19 | 20 | void tick() 21 | { 22 | int i = 10; 23 | while (i) 24 | { 25 | std::cout << "."; 26 | i--; 27 | std::this_thread::sleep_for(std::chrono::milliseconds(1000)); 28 | } 29 | } 30 | 31 | int main() 32 | { 33 | std::thread t1(tick); // tick 1s 34 | std::future f = std::async(std::launch::async, getting_data); // launching a long time operation 35 | // std::future f = std::async(std::launch::deferred, getting_data); // deferred launching a long time operation 36 | // std::future f = std::async(std::launch::async, getting_data_quick, 10); // launching a quick time operation 37 | 38 | std::cout << std::boolalpha << f.valid() << std::endl; 39 | 40 | std::this_thread::sleep_for(std::chrono::milliseconds(5000)); // performs other actions 41 | 42 | auto i = f.get(); // getting result 43 | std::cout << i << std::endl; 44 | std::cout << std::boolalpha << f.valid() << std::endl; 45 | 46 | t1.join(); 47 | return 0; 48 | } -------------------------------------------------------------------------------- /cpp18/lectures/04_multithreads/sources/08a.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | // future & async simple sample 7 | 8 | int getting_data() 9 | { 10 | std::this_thread::sleep_for(std::chrono::seconds(3)); 11 | return 42; 12 | } 13 | 14 | void print_future(std::shared_future f) 15 | { 16 | std::this_thread::sleep_for(std::chrono::milliseconds(500)); 17 | std::cout << f.get() << std::endl; 18 | } 19 | 20 | void tick() 21 | { 22 | int i = 4; 23 | while (i) 24 | { 25 | std::cout << "."; 26 | i--; 27 | std::this_thread::sleep_for(std::chrono::milliseconds(1000)); 28 | } 29 | } 30 | 31 | int main() 32 | { 33 | std::thread t1(tick); // tick 1s 34 | auto sf = std::async(std::launch::async, getting_data).share(); 35 | 36 | std::thread t2(print_future, sf); 37 | std::thread t3(print_future, sf); 38 | std::thread t4(print_future, sf); 39 | 40 | t1.join(); 41 | t2.join(); 42 | t3.join(); 43 | t4.join(); 44 | return 0; 45 | } -------------------------------------------------------------------------------- /cpp18/lectures/04_multithreads/sources/09.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | // catch exception from thread 7 | 8 | 9 | int getting_data() 10 | { 11 | std::this_thread::sleep_for(std::chrono::milliseconds(3000)); 12 | 13 | throw 42; 14 | return 42; 15 | } 16 | 17 | void tick() 18 | { 19 | int i = 10; 20 | while (i) 21 | { 22 | std::cout << "."; 23 | i--; 24 | std::this_thread::sleep_for(std::chrono::seconds(1)); 25 | } 26 | } 27 | 28 | int main() 29 | { 30 | std::thread t1(tick); // tick 1s 31 | std::future f = std::async(std::launch::async, getting_data); 32 | 33 | try 34 | { 35 | auto i = f.get(); // getting result 36 | std::cout << i << std::endl; 37 | } 38 | catch (int i) 39 | { 40 | std::cout << "catch " << i << std::endl; 41 | } 42 | 43 | t1.join(); 44 | return 0; 45 | } -------------------------------------------------------------------------------- /cpp18/lectures/04_multithreads/sources/10.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #if _MSC_VER <= 1800 5 | // VS 2013 doesn't support thread_local keyword 6 | #define thread_local __declspec(thread) 7 | #endif 8 | 9 | static thread_local unsigned int thread_var = 0; 10 | static unsigned int global_var = 0; 11 | 12 | void foo_thread() 13 | { 14 | for (int i = 0; i < 10; i++) 15 | { 16 | std::cout << std::this_thread::get_id() << ":" << thread_var++ << std::endl; 17 | std::this_thread::sleep_for(std::chrono::milliseconds(100)); 18 | } 19 | } 20 | 21 | 22 | void foo_global() 23 | { 24 | for (int i = 0; i < 10; i++) 25 | { 26 | std::cout << std::this_thread::get_id() << ":" << global_var++ << std::endl; 27 | std::this_thread::sleep_for(std::chrono::milliseconds(100)); 28 | } 29 | } 30 | 31 | 32 | int main() 33 | { 34 | 35 | std::thread(foo_global).detach(); 36 | std::thread(foo_global).detach(); 37 | std::thread(foo_global).detach(); 38 | std::thread(foo_global).detach(); 39 | std::thread(foo_global).join(); 40 | std::cout << "GLOBAL = " << global_var << std::endl; 41 | std::cout << "----------------------------" << std::endl; 42 | 43 | 44 | std::thread(foo_thread).detach(); 45 | std::thread(foo_thread).detach(); 46 | std::thread(foo_thread).detach(); 47 | std::thread(foo_thread).detach(); 48 | std::thread(foo_thread).join(); 49 | std::cout << "THREAD = " << thread_var << std::endl; 50 | 51 | return 0; 52 | } -------------------------------------------------------------------------------- /cpp18/lectures/05_network/code/client.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using boost::asio::ip::tcp; 6 | 7 | int main(int argc, char* argv[]) 8 | { 9 | try { 10 | boost::asio::io_service io_service; 11 | 12 | tcp::endpoint ep(boost::asio::ip::address::from_string("127.0.0.1"), 8000); 13 | 14 | tcp::socket socket(io_service, ep.protocol()); 15 | socket.connect(ep); 16 | 17 | boost::array buf; 18 | boost::system::error_code error; 19 | 20 | socket.write_some(boost::asio::buffer("Boost.Asio client")); 21 | 22 | int len = 0; 23 | while (len = socket.read_some(boost::asio::buffer(buf), error)) { 24 | if (error == boost::asio::error::eof) { 25 | 26 | break; 27 | } else if (error) { 28 | throw boost::system::system_error(error); 29 | } 30 | 31 | std::cout.write(buf.data(), len); 32 | } 33 | } catch (std::exception& e) { 34 | std::cerr << e.what() << std::endl; 35 | } 36 | 37 | return 0; 38 | } -------------------------------------------------------------------------------- /cpp18/lectures/05_network/code/server_asio.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | using boost::asio::ip::tcp; 8 | 9 | std::string make_http_message(const char* data, int len) 10 | { 11 | std::string ua(data, len); 12 | std::stringstream response_body; 13 | std::stringstream response; 14 | response_body << "Test C++ HTTP Server\n" 15 | << "

Test page

\n" 16 | << "

This is body of the test page...

\n" 17 | << "

Request headers

\n" 18 | << "
" << ua << "
\n" 19 | << "Test C++ Http Server\n"; 20 | 21 | // ‘ормируем весь ответ вместе с заголовками 22 | response << "HTTP/1.1 200 OK\r\n" 23 | << "Version: HTTP/1.1\r\n" 24 | << "Content-Type: text/html; charset=utf-8\r\n" 25 | << "Content-Length: " << response_body.str().length() 26 | << "\r\n\r\n" 27 | << response_body.str(); 28 | return response.str(); 29 | } 30 | 31 | int main() 32 | { 33 | try 34 | { 35 | // Any program that uses asio need to have at least one io_service object 36 | boost::asio::io_service io_service; 37 | 38 | // acceptor object needs to be created to listen for new connections 39 | tcp::acceptor acceptor(io_service, tcp::endpoint(tcp::v4(), 8000)); 40 | 41 | for (;;) 42 | { 43 | // creates a socket 44 | tcp::socket socket(io_service); 45 | 46 | // wait and listen 47 | acceptor.accept(socket); 48 | 49 | boost::array buf; 50 | boost::system::error_code error; 51 | size_t len = socket.read_some(boost::asio::buffer(buf), error); 52 | 53 | std::string message = make_http_message(buf.data(), len); 54 | 55 | boost::system::error_code ignored_error; 56 | boost::asio::write(socket, boost::asio::buffer(message), ignored_error); 57 | } 58 | } 59 | catch (std::exception& e) 60 | { 61 | std::cerr << e.what() << std::endl; 62 | } 63 | 64 | return 0; 65 | } -------------------------------------------------------------------------------- /cpp18/lectures/05_network/network.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp18/lectures/05_network/network.pdf -------------------------------------------------------------------------------- /cpp18/lectures/06_synchronization/sources/lec/01.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | template 7 | class SafeQueue 8 | { 9 | public: 10 | void Push(const T& data) 11 | { 12 | std::lock_guard lk(Mutex); 13 | Queue.push(data); 14 | } 15 | 16 | T Pop() 17 | { 18 | std::lock_guard lk(Mutex); 19 | T data = Queue.front(); 20 | Queue.pop(); 21 | return data; 22 | } 23 | 24 | private: 25 | std::queue Queue; 26 | std::mutex Mutex; 27 | }; 28 | 29 | SafeQueue queue; 30 | 31 | void foo() 32 | { 33 | for (int i = 0; i < 10; ++i) 34 | { 35 | queue.Push(i); 36 | std::this_thread::sleep_for(std::chrono::microseconds(10)); 37 | } 38 | } 39 | 40 | int main() 41 | { 42 | std::thread t1(foo); 43 | std::thread t2(foo); 44 | 45 | t1.join(); 46 | t2.join(); 47 | 48 | for (int i = 0; i < 20; ++i) 49 | { 50 | std::cout << queue.Pop() << std::endl; 51 | } 52 | 53 | return 0; 54 | } -------------------------------------------------------------------------------- /cpp18/lectures/06_synchronization/sources/lec/02.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | // cv simple sample 6 | 7 | std::mutex m; 8 | bool flag = false; 9 | std::condition_variable cv; 10 | 11 | void waiting_cv() 12 | { 13 | std::unique_lock lk(m); 14 | 15 | cv.wait(lk, [](){ 16 | std::cout << ".."; 17 | return flag; 18 | }); 19 | 20 | // using flag 21 | std::cout << std::endl << std::boolalpha << flag; 22 | } 23 | 24 | void process() 25 | { 26 | std::lock_guard lk(m); 27 | std::this_thread::sleep_for(std::chrono::milliseconds(500)); // some action 28 | flag = true; 29 | cv.notify_one(); // data is ready 30 | } 31 | 32 | int main() 33 | { 34 | std::thread t1(waiting_cv); 35 | std::thread t2(process); 36 | 37 | t1.join(); 38 | t2.join(); 39 | 40 | return 0; 41 | } -------------------------------------------------------------------------------- /cpp18/lectures/06_synchronization/sources/lec/03.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | // cv simple sample. testing queue 7 | 8 | std::mutex m; 9 | std::queue q; 10 | std::condition_variable cv; 11 | 12 | void waiting_cv() 13 | { 14 | int r = -1; 15 | while (r != 9) 16 | { 17 | std::unique_lock lk(m); 18 | cv.wait(lk, [](){ 19 | std::cout << ".."; 20 | return !q.empty(); 21 | }); // wait while q.empty() 22 | 23 | // lk is already locked 24 | // we can using queue 25 | r = q.front(); 26 | q.pop(); 27 | lk.unlock(); 28 | 29 | std::cout << std::endl << std::boolalpha << r; 30 | std::this_thread::sleep_for(std::chrono::milliseconds(100)); // some action 31 | } 32 | } 33 | 34 | void waiting_for_cv() 35 | { 36 | int r = -1; 37 | while (r != 9) 38 | { 39 | std::unique_lock lk(m); 40 | 41 | // wait for 100 milliseconds 42 | auto pred_result = cv.wait_for(lk, 43 | std::chrono::milliseconds(100), 44 | [](){ 45 | std::cout << ".."; 46 | return !q.empty(); 47 | }); 48 | 49 | if (!pred_result) // if q.empty() continue; else we can using queue 50 | continue; 51 | 52 | // lk is already locked 53 | // we can using queue 54 | r = q.front(); 55 | q.pop(); 56 | lk.unlock(); 57 | 58 | std::cout << std::endl << std::boolalpha << r; 59 | std::this_thread::sleep_for(std::chrono::milliseconds(100)); // some action 60 | } 61 | } 62 | 63 | void process() 64 | { 65 | int i = 0; 66 | while (i < 10) 67 | { 68 | std::this_thread::sleep_for(std::chrono::milliseconds(500)); // some action 69 | std::lock_guard lk(m); // lock 70 | q.push(i++); // push data 71 | cv.notify_one(); // data is ready 72 | } 73 | } 74 | 75 | int main() 76 | { 77 | std::thread t1(waiting_cv); 78 | std::thread t2(process); 79 | 80 | t1.join(); 81 | t2.join(); 82 | 83 | return 0; 84 | } -------------------------------------------------------------------------------- /cpp18/lectures/06_synchronization/sources/lec/04.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | // cv simple sample. testing queue 7 | 8 | std::mutex m; 9 | std::queue q; 10 | std::condition_variable cv; 11 | 12 | void consumer() 13 | { 14 | int r = -1; 15 | while (r != 9) 16 | { 17 | std::unique_lock lk(m); 18 | cv.wait(lk, [](){ 19 | std::cout << ".."; 20 | return !q.empty(); 21 | }); // wait while q.empty() 22 | 23 | // lk is already locked 24 | // we can using queue 25 | r = q.front(); 26 | q.pop(); 27 | lk.unlock(); 28 | 29 | std::cout << std::endl << std::boolalpha << r; 30 | std::this_thread::sleep_for(std::chrono::microseconds(100)); // some action 31 | } 32 | } 33 | 34 | void producer() 35 | { 36 | int i = 0; 37 | while (i < 10) 38 | { 39 | std::this_thread::sleep_for(std::chrono::milliseconds(500)); // some action 40 | std::lock_guard lk(m); // lock 41 | q.push(i++); // push data 42 | cv.notify_one(); // data is ready 43 | } 44 | } 45 | 46 | int main() 47 | { 48 | std::thread t1(consumer); 49 | std::thread t2(producer); 50 | std::thread t3(producer); 51 | 52 | t1.join(); 53 | t2.join(); 54 | t3.join(); 55 | 56 | return 0; 57 | } -------------------------------------------------------------------------------- /cpp18/lectures/06_synchronization/sources/lec/05.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | // Demonstrate data race 10 | 11 | uint64_t g_sum = 0; 12 | std::atomic g_a_sum = 0; 13 | 14 | void summ(unsigned long long a, unsigned long long b) 15 | { 16 | for (unsigned long long i = a; i < b; i++) 17 | { 18 | g_sum = g_sum + i; 19 | } 20 | } 21 | 22 | void atomic_summ(unsigned long long a, unsigned long long b) 23 | { 24 | for (unsigned long long i = a; i < b; i++) 25 | { 26 | g_a_sum += i; // or fetch_add 27 | // g_a_sum.fetch_add(i); 28 | } 29 | } 30 | 31 | int main() 32 | { 33 | const unsigned long long n = 10000000; 34 | 35 | std::thread t1(summ, 0, n); 36 | std::thread t2(summ, n, 2 * n); 37 | std::thread t3(summ, 2 * n, 3 * n); 38 | std::thread t4(summ, 3 * n, (4 * n) + 1); 39 | 40 | std::thread t1_a(atomic_summ, 0, n); 41 | std::thread t2_a(atomic_summ, n, 2 * n); 42 | std::thread t3_a(atomic_summ, 2 * n, 3 * n); 43 | std::thread t4_a(atomic_summ, 3 * n, (4 * n) + 1); 44 | 45 | t1_a.join(); 46 | t2_a.join(); 47 | t3_a.join(); 48 | t4_a.join(); 49 | 50 | t1.join(); 51 | t2.join(); 52 | t3.join(); 53 | t4.join(); 54 | 55 | std::cout << "summ = " << g_sum << std::endl; 56 | std::cout << "summ = " << g_a_sum << std::endl; 57 | std::cout << "answer = " << (n * 4) * (4 * n + 1) / 2 << std::endl; 58 | 59 | return 0; 60 | } -------------------------------------------------------------------------------- /cpp18/lectures/06_synchronization/sources/thread_pool/main.cpp: -------------------------------------------------------------------------------- 1 | #include "thread_pool.h" 2 | 3 | #include 4 | 5 | void foo(int time) 6 | { 7 | std::cout << "begin on " << std::this_thread::get_id() << std::endl; 8 | std::this_thread::sleep_for(std::chrono::seconds(time)); 9 | std::cout << "end on " << std::this_thread::get_id() << std::endl; 10 | } 11 | 12 | int bar(int time) 13 | { 14 | std::cout << "returns " << time << " on " << std::this_thread::get_id() << std::endl; 15 | return time; 16 | } 17 | 18 | int main() 19 | { 20 | thread_pool pool(8); 21 | 22 | pool.submit(foo, 10); 23 | pool.submit(foo, 10); 24 | pool.submit(foo, 10); 25 | pool.submit(foo, 10); 26 | auto f = pool.submit([](int time) 27 | { 28 | std::cout << "returns " << time << " on " << std::this_thread::get_id() << std::endl; 29 | return time; 30 | }, 10); 31 | pool.submit(bar, 10).get(); 32 | 33 | 34 | std::cout << f.get(); 35 | std::this_thread::sleep_for(std::chrono::seconds(2)); 36 | } -------------------------------------------------------------------------------- /cpp18/lectures/06_synchronization/sources/thread_pool/thread_pool.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | 8 | class thread_pool 9 | { 10 | public: 11 | 12 | thread_pool() 13 | { 14 | _start(); 15 | } 16 | 17 | thread_pool(size_t num) : 18 | _num(num) 19 | { 20 | _start(); 21 | } 22 | 23 | ~thread_pool() 24 | { 25 | std::unique_lock lk(_m); 26 | _stop = true; 27 | lk.unlock(); 28 | 29 | cv.notify_all(); 30 | for (auto & t : _threads) 31 | t.join(); 32 | } 33 | 34 | template 35 | std::future> submit(F && func, Args && ... args) 36 | { 37 | using result_type = std::result_of_t; 38 | 39 | auto ptr_task = std::make_shared>( 40 | std::bind(std::forward(func), std::forward(args)... )); 41 | 42 | auto result = ptr_task->get_future(); 43 | 44 | std::lock_guard lk(_m); 45 | _tasks.emplace([ptr_task]() -> void 46 | { 47 | (*ptr_task)(); 48 | }); 49 | 50 | cv.notify_one(); 51 | return result; 52 | } 53 | 54 | private: 55 | size_t _num = std::thread::hardware_concurrency(); 56 | std::queue> _tasks; 57 | std::vector _threads; 58 | std::mutex _m; 59 | std::condition_variable cv; 60 | bool _stop; 61 | 62 | void _working_thread_func() 63 | { 64 | while (true) 65 | { 66 | std::unique_lock lk(_m); 67 | cv.wait(lk, [this]() 68 | { 69 | return _stop || !this->_tasks.empty(); 70 | }); 71 | 72 | if (_stop) 73 | return; 74 | 75 | auto task = _tasks.front(); 76 | _tasks.pop(); 77 | lk.unlock(); 78 | 79 | task(); 80 | } 81 | } 82 | 83 | void _start() 84 | { 85 | _stop = false; 86 | for (size_t i = 0; i < _num; i++) 87 | _threads.push_back(std::thread(&thread_pool::_working_thread_func, this)); 88 | } 89 | }; 90 | -------------------------------------------------------------------------------- /cpp18/lectures/06_synchronization/synchronization.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp18/lectures/06_synchronization/synchronization.pdf -------------------------------------------------------------------------------- /cpp18/lectures/06_synchronization/thread_pool.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp18/lectures/06_synchronization/thread_pool.pdf -------------------------------------------------------------------------------- /cpp19/02_smart_pointers.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp19/02_smart_pointers.pdf -------------------------------------------------------------------------------- /cpp19/04_multithreads.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp19/04_multithreads.pdf -------------------------------------------------------------------------------- /cpp19/lec_02/source/lec_02_source/custom_deleters.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp19/lec_02/source/lec_02_source/custom_deleters.cpp -------------------------------------------------------------------------------- /cpp19/lec_02/source/lec_02_source/file_storage.cpp: -------------------------------------------------------------------------------- 1 | #include "file_storage.h" 2 | 3 | FileStorage::FileStorage(const std::string& filename) : stream_(filename) {} 4 | 5 | bool FileStorage::IsValid() const { 6 | return stream_.is_open() && !stream_.eof(); 7 | } 8 | 9 | bool FileStorage::OnUserSave(const std::string& user) { 10 | if (!IsValid()) 11 | return false; 12 | 13 | stream_ << user << std::endl; 14 | return true; 15 | } 16 | -------------------------------------------------------------------------------- /cpp19/lec_02/source/lec_02_source/file_storage.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "storage.h" 7 | 8 | class FileStorage : public Storage { 9 | public: 10 | FileStorage(const std::string& filename); 11 | ~FileStorage() = default; 12 | 13 | bool OnUserSave(const std::string& user) override; 14 | 15 | bool IsValid() const; 16 | 17 | private: 18 | std::fstream stream_; 19 | }; 20 | -------------------------------------------------------------------------------- /cpp19/lec_02/source/lec_02_source/http_server.cpp: -------------------------------------------------------------------------------- 1 | #include "http_server.h" 2 | 3 | HttpServer::HttpServer(std::unique_ptr storage) 4 | : storage_(std::move(storage)) {} 5 | 6 | std::string HttpServer::Save(const std::string& user) { 7 | return storage_->OnUserSave(user) ? "ok" : "error"; 8 | } 9 | -------------------------------------------------------------------------------- /cpp19/lec_02/source/lec_02_source/http_server.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "storage.h" 4 | 5 | class HttpServer { 6 | public: 7 | HttpServer(std::unique_ptr storage); 8 | 9 | std::string Save(const std::string& user); 10 | 11 | private: 12 | std::unique_ptr storage_; 13 | }; 14 | -------------------------------------------------------------------------------- /cpp19/lec_02/source/lec_02_source/lec_02_source.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /cpp19/lec_02/source/lec_02_source/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | #include "file_storage.h" 11 | #include "http_server.h" 12 | #include "sql_connection.h" 13 | 14 | void ThreadWorker(std::shared_ptr connection) { 15 | using namespace std::chrono_literals; 16 | std::this_thread::sleep_for(100ms); 17 | connection->ExecuteQuery("SELECT* FROM Table WHERE group = 'iu8'"); 18 | // ... 19 | } 20 | 21 | int main() { 22 | // Unique ptr sample. 23 | std::unique_ptr file_storage = 24 | std::make_unique("db.txt"); 25 | 26 | HttpServer server(std::move(file_storage)); 27 | 28 | std::cout << server.Save("user one") << std::endl; 29 | std::cout << server.Save("user two") << std::endl; 30 | std::cout << server.Save("user three") << std::endl; 31 | 32 | // Shared ptr example. 33 | std::shared_ptr sql_connection = 34 | SQLConnection::Create("postgresql://localost:5000/students"); 35 | 36 | std::thread th1(ThreadWorker, sql_connection); 37 | std::thread th2(ThreadWorker, sql_connection); 38 | std::thread th3(ThreadWorker, sql_connection); 39 | std::thread th4(ThreadWorker, sql_connection); 40 | 41 | th1.join(); 42 | th2.join(); 43 | th3.join(); 44 | th4.join(); 45 | 46 | return 0; 47 | } 48 | -------------------------------------------------------------------------------- /cpp19/lec_02/source/lec_02_source/sql_connection.cpp: -------------------------------------------------------------------------------- 1 | #include "sql_connection.h" 2 | 3 | void SQLConnection::ExecuteQuery(std::string_view query) { 4 | log_file_ << "Executing query: " << query << std::endl; 5 | 6 | // ... 7 | } 8 | 9 | // static 10 | std::shared_ptr SQLConnection::Create( 11 | const std::string& db_uri) { 12 | SQLConnection* raw = new SQLConnection(db_uri); 13 | return std::shared_ptr(raw); 14 | } 15 | 16 | SQLConnection::SQLConnection(const std::string& db_uri) 17 | : log_file_("log_0000.txt") { 18 | if (log_file_.is_open()) { 19 | log_file_ << "Connection to " << db_uri << std::endl; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /cpp19/lec_02/source/lec_02_source/sql_connection.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class SQLConnection { 10 | public: 11 | // Not thread-safe. 12 | void ExecuteQuery(std::string_view query); 13 | 14 | static std::shared_ptr Create(const std::string& db_uri); 15 | 16 | private: 17 | SQLConnection(const std::string& db_uri); 18 | 19 | std::ofstream log_file_; 20 | }; 21 | -------------------------------------------------------------------------------- /cpp19/lec_02/source/lec_02_source/storage.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | struct Storage { 6 | virtual ~Storage() = default; 7 | virtual bool OnUserSave(const std::string& user) = 0; 8 | }; 9 | -------------------------------------------------------------------------------- /cpp19/lec_02/source/smart_pointers.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.489 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lec_02_source", "lec_02_source\lec_02_source.vcxproj", "{285BBEAB-43A2-4A98-9D2C-53899C605DD5}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {285BBEAB-43A2-4A98-9D2C-53899C605DD5}.Debug|x64.ActiveCfg = Debug|x64 17 | {285BBEAB-43A2-4A98-9D2C-53899C605DD5}.Debug|x64.Build.0 = Debug|x64 18 | {285BBEAB-43A2-4A98-9D2C-53899C605DD5}.Debug|x86.ActiveCfg = Debug|Win32 19 | {285BBEAB-43A2-4A98-9D2C-53899C605DD5}.Debug|x86.Build.0 = Debug|Win32 20 | {285BBEAB-43A2-4A98-9D2C-53899C605DD5}.Release|x64.ActiveCfg = Release|x64 21 | {285BBEAB-43A2-4A98-9D2C-53899C605DD5}.Release|x64.Build.0 = Release|x64 22 | {285BBEAB-43A2-4A98-9D2C-53899C605DD5}.Release|x86.ActiveCfg = Release|Win32 23 | {285BBEAB-43A2-4A98-9D2C-53899C605DD5}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {F5841E0B-AC86-4118-9468-A844A9422608} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /cpp19/lec_04/lec_04_source/browser_suggest.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp19/lec_04/lec_04_source/browser_suggest.cpp -------------------------------------------------------------------------------- /cpp19/lec_04/lec_04_source/http_server.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp19/lec_04/lec_04_source/http_server.cpp -------------------------------------------------------------------------------- /cpp19/lec_04/lec_04_source/lec_04_source.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /cpp19/lec_04/threads.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.489 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lec_04_source", "lec_04_source\lec_04_source.vcxproj", "{285BBEAB-43A2-4A98-9D2C-53899C605DD5}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {285BBEAB-43A2-4A98-9D2C-53899C605DD5}.Debug|x64.ActiveCfg = Debug|x64 17 | {285BBEAB-43A2-4A98-9D2C-53899C605DD5}.Debug|x64.Build.0 = Debug|x64 18 | {285BBEAB-43A2-4A98-9D2C-53899C605DD5}.Debug|x86.ActiveCfg = Debug|Win32 19 | {285BBEAB-43A2-4A98-9D2C-53899C605DD5}.Debug|x86.Build.0 = Debug|Win32 20 | {285BBEAB-43A2-4A98-9D2C-53899C605DD5}.Release|x64.ActiveCfg = Release|x64 21 | {285BBEAB-43A2-4A98-9D2C-53899C605DD5}.Release|x64.Build.0 = Release|x64 22 | {285BBEAB-43A2-4A98-9D2C-53899C605DD5}.Release|x86.ActiveCfg = Release|Win32 23 | {285BBEAB-43A2-4A98-9D2C-53899C605DD5}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {F5841E0B-AC86-4118-9468-A844A9422608} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /cpp19/lec_05/source/.clang-format: -------------------------------------------------------------------------------- 1 | # Defines the Chromium style for automatic reformatting. 2 | # http://clang.llvm.org/docs/ClangFormatStyleOptions.html 3 | BasedOnStyle: Google 4 | # This defaults to 'Auto'. Explicitly set it for a while, so that 5 | # 'vector >' in existing files gets formatted to 6 | # 'vector>'. ('Auto' means that clang-format will only use 7 | # 'int>>' if the file already contains at least one such instance.) 8 | Standard: Cpp11 9 | -------------------------------------------------------------------------------- /cpp19/lec_05/source/.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | -------------------------------------------------------------------------------- /cpp19/lec_05/source/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "tools/polly"] 2 | path = tools/polly 3 | url = https://github.com/cpp-pm/polly 4 | [submodule "tools/gate"] 5 | path = tools/gate 6 | url = https://github.com/cpp-pm/gate 7 | -------------------------------------------------------------------------------- /cpp19/lec_05/source/.travis.yml: -------------------------------------------------------------------------------- 1 | os: linux 2 | sudo: required 3 | language: 4 | - minimal 5 | services: 6 | - docker 7 | 8 | jobs: 9 | include: 10 | - name: "checks" 11 | script: 12 | - docker run -v `pwd`:`pwd` -w `pwd` --cap-add=SYS_PTRACE -t rusdevops/bootstrap-cpp scripts/checks.sh 13 | - name: "tests" 14 | script: 15 | - docker run -v `pwd`:`pwd` -w `pwd` -t rusdevops/bootstrap-cpp scripts/tests.sh 16 | - name: "quality" 17 | script: 18 | - ./scripts/genenv.sh 19 | - docker run --env-file .env -v `pwd`:`pwd` -w `pwd` -t rusdevops/bootstrap-cpp scripts/coverage.sh 20 | # The bot has gone... 21 | # - docker run --env-file .env -v `pwd`:`pwd` -w `pwd` -t rusdevops/bootstrap-cpp scripts/duplication.sh 22 | 23 | notifications: 24 | email: false 25 | 26 | branches: 27 | except: 28 | - master 29 | -------------------------------------------------------------------------------- /cpp19/lec_05/source/AUTHORS: -------------------------------------------------------------------------------- 1 | Andrey Borodin 2 | Vladislav Vershinin 3 | Vyacheslav Vershinin 4 | Georgy Baydin 5 | Igor Matsak 6 | -------------------------------------------------------------------------------- /cpp19/lec_05/source/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.4) 2 | 3 | set(CMAKE_CXX_STANDARD 17) 4 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 5 | 6 | option(BUILD_COVERAGE "Build coverage" OFF) 7 | 8 | set( 9 | HUNTER_CACHE_SERVERS 10 | "https://github.com/bmstu-iu8-cpp-sem-3/hunter-cache" 11 | CACHE STRING "Default cache server" 12 | ) 13 | 14 | include("tools/gate/cmake/HunterGate.cmake") 15 | 16 | HunterGate( 17 | URL "https://github.com/cpp-pm/hunter/archive/v0.23.218.tar.gz" 18 | SHA1 "9a3594a61227967fb92159339ba326701b287b19" 19 | ) 20 | 21 | project(network_lecture) 22 | 23 | hunter_add_package(Boost) 24 | find_package(Boost CONFIG REQUIRED) 25 | 26 | add_executable(server 27 | # TODO: enum your files and delete this comment 28 | ${CMAKE_CURRENT_SOURCE_DIR}/sources/source.cpp 29 | ) 30 | 31 | target_include_directories(server 32 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 33 | ) 34 | 35 | target_link_libraries(server Boost::boost) 36 | 37 | -------------------------------------------------------------------------------- /cpp19/lec_05/source/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ### Example of creating an new lab 2 | 3 | ```Shell 4 | export LAB_NUMBER=xx 5 | export LAB_KEYWORD=yyyyyyy 6 | export LAB_NAME=lab-${LAB_NUMBER}-${LAB_KEYWORD} 7 | git clone https://github.com/bmstu-iu8-cpp-sem-3/lab-xx-template ${LAB_NAME} 8 | cd ${LAB_NAME} 9 | git remote rename origin template 10 | git remote add origin https://github.com/bmstu-iu8-cpp-sem-3/${LAB_NAME}.git 11 | # 1. remove the unnecessary directories 12 | # 2. add the necessary files 13 | git add . 14 | git commit -m"prepared ${LAB_NAME}" 15 | git push origin master 16 | ``` 17 | 18 | ### Example of updating an existing lab 19 | 20 | ```Shell 21 | export LAB_NUMBER=xx 22 | export LAB_KEYWORD=yyyyyyy 23 | export LAB_NAME=lab-${LAB_NUMBER}-${LAB_KEYWORD} 24 | git clone https://github.com/bmstu-iu8-cpp-sem-3/${LAB_NAME} 25 | cd ${LAB_NAME} 26 | git remote rename origin template 27 | git remote add template https://github.com/bmstu-iu8-cpp-sem-3/lab-xx-template.git 28 | git fetch template master 29 | git branch -f template template/master 30 | git rebase template 31 | git push -f origin master 32 | ``` 33 | -------------------------------------------------------------------------------- /cpp19/lec_05/source/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:18.04 2 | LABEL maintainer="rusdevops@gmail.com" 3 | 4 | RUN apt update && apt install -y software-properties-common && \ 5 | apt-add-repository -y "ppa:ubuntu-toolchain-r/test" && apt update && \ 6 | apt install -y wget && wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - && \ 7 | apt-add-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-7 main" && \ 8 | apt install -y libcurl4-gnutls-dev curl nodejs npm \ 9 | g++-7 lcov gcovr cmake cmake-data python3-pip clang-7 && \ 10 | rm -rf /var/lib/apt/lists/* && \ 11 | pip3 install cpplint && npm install -g jscpd && \ 12 | apt -y autoremove && ln -s /usr/bin/clang-7 /usr/bin/clang && \ 13 | ln -s /usr/bin/clang++-7 /usr/bin/clang++ && \ 14 | ln -s /usr/bin/clang-cpp-7 /usr/bin/clang-cpp 15 | -------------------------------------------------------------------------------- /cpp19/lec_05/source/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016-2018 The ISC Authors. 2 | 3 | All rights reserved. 4 | 5 | MIT License 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | -------------------------------------------------------------------------------- /cpp19/lec_05/source/images/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /cpp19/lec_05/source/include/header.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Your Name 2 | 3 | #ifndef INCLUDE_HEADER_HPP_ 4 | #define INCLUDE_HEADER_HPP_ 5 | 6 | #endif // INCLUDE_HEADER_HPP_ 7 | -------------------------------------------------------------------------------- /cpp19/lec_05/source/misc/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp19/lec_05/source/misc/.gitkeep -------------------------------------------------------------------------------- /cpp19/lec_05/source/scripts/checks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | files=`find . -name "*.cpp" -or -name "*.hpp" -or -name ".h" | grep -v "./tools/*"` 5 | filter=-build/c++11,-runtime/references,-whitespace/braces,-whitespace/indent,-whitespace/comments,-build/include_order 6 | echo $files | xargs cpplint --filter=$filter 7 | 8 | export CTEST_OUTPUT_ON_FAILURE=true 9 | # address sanitizer 10 | #CMAKE_LINKER_OPTS="-DCMAKE_EXE_LINKER='-fuse-ld=gold'" 11 | CMAKE_CONFIG_OPTS="-DHUNTER_CONFIGURATION_TYPES=Debug -DCMAKE_BUILD_TYPE=Debug" 12 | CMAKE_TOOLCHAIN_OPTS="-DCMAKE_TOOLCHAIN_FILE='`pwd`/tools/polly/sanitize-address-cxx17-pic.cmake'" 13 | CMAKE_OPTS="$CMAKE_LINKER_OPTS $CMAKE_CONFIG_OPTS $CMAKE_TOOLCHAIN_OPTS" 14 | cmake -H. -B_builds/sanitize-address-cxx17 $CMAKE_OPTS 15 | cmake --build _builds/sanitize-address-cxx17 16 | ./_builds/sanitize-address-cxx17/tests 17 | # thread sanitizer 18 | CMAKE_TOOLCHAIN_OPTS="-DCMAKE_TOOLCHAIN_FILE='`pwd`/tools/polly/sanitize-thread-cxx17-pic.cmake'" 19 | CMAKE_OPTS="$CMAKE_LINKER_OPTS $CMAKE_CONFIG_OPTS $CMAKE_TOOLCHAIN_OPTS" 20 | cmake -H. -B_builds/sanitize-thread-cxx17 $CMAKE_OPTS 21 | cmake --build _builds/sanitize-thread-cxx17 22 | ./_builds/sanitize-thread-cxx17/tests 23 | -------------------------------------------------------------------------------- /cpp19/lec_05/source/scripts/coverage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | export GTEST_COLOR=1 5 | export CTEST_OUTPUT_ON_FAILURE=true 6 | 7 | CMAKE_LINKER_OPTS="-DCMAKE_EXE_LINKER='-fuse-ld=gold'" 8 | CMAKE_CONFIG_OPTS="-DHUNTER_CONFIGURATION_TYPES=Debug -DCMAKE_BUILD_TYPE=Debug" 9 | CMAKE_TOOLCHAIN_OPTS="-DCMAKE_TOOLCHAIN_FILE='`pwd`/tools/polly/gcc-7-cxx17-pic.cmake'" 10 | CMAKE_OPTS="$CMAKE_LINKER_OPTS $CMAKE_CONFIG_OPTS $CMAKE_TOOLCHAIN_OPTS" 11 | 12 | cmake -H. -B_builds $CMAKE_OPTS -DBUILD_COVERAGE=ON 13 | cmake --build _builds 14 | cmake --build _builds --target test 15 | cmake --build _builds --target gcov 16 | cmake --build _builds --target lcov 17 | gcovr -r . 18 | 19 | REPORT_DATA=$(gcovr -r . | base64 | tr -d '\n') 20 | POST_DATA="{\"report\": \"$REPORT_DATA\", \"slug\": \"$TRAVIS_REPO_SLUG\", \"head_branch\": \"$TRAVIS_BRANCH\", \"head_sha\": \"$TRAVIS_COMMIT\"}" 21 | 22 | if [[ $TRAVIS_PULL_REQUEST == 'false' ]]; then 23 | curl -H "Content-Type: application/json" -d "$POST_DATA" -X POST http://borodin.dev.bmstu.cloud/api/coverage/ 24 | fi 25 | -------------------------------------------------------------------------------- /cpp19/lec_05/source/scripts/duplication.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | jscpd --mode "weak" --format "cpp" --ignore "_builds/**" . 6 | 7 | REPORT_DATA=$(jscpd --mode "weak" --format "cpp" --ignore "_builds/**" . | sed -r "s/[[:cntrl:]]\[[0-9]{1,3}m//g" | base64 | tr -d '\n') 8 | POST_DATA="{\"report\": \"$REPORT_DATA\", \"slug\": \"$TRAVIS_REPO_SLUG\", \"head_branch\": \"$TRAVIS_BRANCH\", \"head_sha\": \"$TRAVIS_COMMIT\"}" 9 | 10 | if [[ $TRAVIS_PULL_REQUEST == 'false' ]]; then 11 | curl -H "Content-Type: application/json" -d "$POST_DATA" -X POST http://borodin.dev.bmstu.cloud/api/duplication/ 12 | fi 13 | -------------------------------------------------------------------------------- /cpp19/lec_05/source/scripts/genenv.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | echo "TRAVIS_REPO_SLUG=$TRAVIS_REPO_SLUG" > .env 6 | echo "TRAVIS_PULL_REQUEST=$TRAVIS_PULL_REQUEST" >> .env 7 | echo "TRAVIS_BRANCH=$TRAVIS_BRANCH" >> .env 8 | echo "TRAVIS_COMMIT=$TRAVIS_COMMIT" >> .env -------------------------------------------------------------------------------- /cpp19/lec_05/source/scripts/tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | export GTEST_COLOR=1 4 | CMAKE_LINKER_OPTS="-DCMAKE_EXE_LINKER='-fuse-ld=gold'" 5 | CMAKE_CONFIG_OPTS="-DHUNTER_CONFIGURATION_TYPES=Debug -DCMAKE_BUILD_TYPE=Debug" 6 | CMAKE_TOOLCHAIN_OPTS="-DCMAKE_TOOLCHAIN_FILE='`pwd`/tools/polly/gcc-7-cxx17-pic.cmake'" 7 | CMAKE_OPTS="$CMAKE_LINKER_OPTS $CMAKE_CONFIG_OPTS $CMAKE_TOOLCHAIN_OPTS" 8 | cmake -H. -B_builds $CMAKE_OPTS 9 | cmake --build _builds 10 | cmake --build _builds --target test -- ARGS="--verbose" 11 | -------------------------------------------------------------------------------- /cpp19/lec_05/source/tests/test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Your Name 2 | 3 | #include 4 | 5 | TEST(Example, EmptyTest) { 6 | EXPECT_TRUE(true); 7 | } 8 | -------------------------------------------------------------------------------- /cpp19/lec_05/source/third-party/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp19/lec_05/source/third-party/.gitkeep -------------------------------------------------------------------------------- /cpp19/lec_06/source/.clang-format: -------------------------------------------------------------------------------- 1 | # Defines the Chromium style for automatic reformatting. 2 | # http://clang.llvm.org/docs/ClangFormatStyleOptions.html 3 | BasedOnStyle: Google 4 | # This defaults to 'Auto'. Explicitly set it for a while, so that 5 | # 'vector >' in existing files gets formatted to 6 | # 'vector>'. ('Auto' means that clang-format will only use 7 | # 'int>>' if the file already contains at least one such instance.) 8 | Standard: Cpp11 9 | -------------------------------------------------------------------------------- /cpp19/lec_06/source/.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | -------------------------------------------------------------------------------- /cpp19/lec_06/source/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "tools/polly"] 2 | path = tools/polly 3 | url = https://github.com/cpp-pm/polly 4 | [submodule "tools/gate"] 5 | path = tools/gate 6 | url = https://github.com/cpp-pm/gate 7 | -------------------------------------------------------------------------------- /cpp19/lec_06/source/.travis.yml: -------------------------------------------------------------------------------- 1 | os: linux 2 | sudo: required 3 | language: 4 | - minimal 5 | services: 6 | - docker 7 | 8 | jobs: 9 | include: 10 | - name: "checks" 11 | script: 12 | - docker run -v `pwd`:`pwd` -w `pwd` --cap-add=SYS_PTRACE -t rusdevops/bootstrap-cpp scripts/checks.sh 13 | - name: "tests" 14 | script: 15 | - docker run -v `pwd`:`pwd` -w `pwd` -t rusdevops/bootstrap-cpp scripts/tests.sh 16 | - name: "quality" 17 | script: 18 | - ./scripts/genenv.sh 19 | - docker run --env-file .env -v `pwd`:`pwd` -w `pwd` -t rusdevops/bootstrap-cpp scripts/coverage.sh 20 | # The bot has gone... 21 | # - docker run --env-file .env -v `pwd`:`pwd` -w `pwd` -t rusdevops/bootstrap-cpp scripts/duplication.sh 22 | 23 | notifications: 24 | email: false 25 | 26 | branches: 27 | except: 28 | - master 29 | -------------------------------------------------------------------------------- /cpp19/lec_06/source/AUTHORS: -------------------------------------------------------------------------------- 1 | Andrey Borodin 2 | Vladislav Vershinin 3 | Vyacheslav Vershinin 4 | Georgy Baydin 5 | Igor Matsak 6 | -------------------------------------------------------------------------------- /cpp19/lec_06/source/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.4) 2 | 3 | set(CMAKE_CXX_STANDARD 17) 4 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 5 | 6 | option(BUILD_COVERAGE "Build coverage" OFF) 7 | 8 | set( 9 | HUNTER_CACHE_SERVERS 10 | "https://github.com/bmstu-iu8-cpp-sem-3/hunter-cache" 11 | CACHE STRING "Default cache server" 12 | ) 13 | 14 | include("tools/gate/cmake/HunterGate.cmake") 15 | 16 | HunterGate( 17 | URL "https://github.com/cpp-pm/hunter/archive/v0.23.218.tar.gz" 18 | SHA1 "9a3594a61227967fb92159339ba326701b287b19" 19 | ) 20 | 21 | project(sync_lecture) 22 | 23 | find_package(Threads REQUIRED) 24 | hunter_add_package(Boost) 25 | find_package(Boost CONFIG REQUIRED) 26 | 27 | add_executable(server 28 | # TODO: enum your files and delete this comment 29 | ${CMAKE_CURRENT_SOURCE_DIR}/sources/source.cpp 30 | ) 31 | 32 | target_include_directories(server 33 | PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include 34 | ) 35 | 36 | target_link_libraries(server Boost::boost Threads::Threads) 37 | 38 | -------------------------------------------------------------------------------- /cpp19/lec_06/source/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ### Example of creating an new lab 2 | 3 | ```Shell 4 | export LAB_NUMBER=xx 5 | export LAB_KEYWORD=yyyyyyy 6 | export LAB_NAME=lab-${LAB_NUMBER}-${LAB_KEYWORD} 7 | git clone https://github.com/bmstu-iu8-cpp-sem-3/lab-xx-template ${LAB_NAME} 8 | cd ${LAB_NAME} 9 | git remote rename origin template 10 | git remote add origin https://github.com/bmstu-iu8-cpp-sem-3/${LAB_NAME}.git 11 | # 1. remove the unnecessary directories 12 | # 2. add the necessary files 13 | git add . 14 | git commit -m"prepared ${LAB_NAME}" 15 | git push origin master 16 | ``` 17 | 18 | ### Example of updating an existing lab 19 | 20 | ```Shell 21 | export LAB_NUMBER=xx 22 | export LAB_KEYWORD=yyyyyyy 23 | export LAB_NAME=lab-${LAB_NUMBER}-${LAB_KEYWORD} 24 | git clone https://github.com/bmstu-iu8-cpp-sem-3/${LAB_NAME} 25 | cd ${LAB_NAME} 26 | git remote rename origin template 27 | git remote add template https://github.com/bmstu-iu8-cpp-sem-3/lab-xx-template.git 28 | git fetch template master 29 | git branch -f template template/master 30 | git rebase template 31 | git push -f origin master 32 | ``` 33 | -------------------------------------------------------------------------------- /cpp19/lec_06/source/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:18.04 2 | LABEL maintainer="rusdevops@gmail.com" 3 | 4 | RUN apt update && apt install -y software-properties-common && \ 5 | apt-add-repository -y "ppa:ubuntu-toolchain-r/test" && apt update && \ 6 | apt install -y wget && wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - && \ 7 | apt-add-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-7 main" && \ 8 | apt install -y libcurl4-gnutls-dev curl nodejs npm \ 9 | g++-7 lcov gcovr cmake cmake-data python3-pip clang-7 && \ 10 | rm -rf /var/lib/apt/lists/* && \ 11 | pip3 install cpplint && npm install -g jscpd && \ 12 | apt -y autoremove && ln -s /usr/bin/clang-7 /usr/bin/clang && \ 13 | ln -s /usr/bin/clang++-7 /usr/bin/clang++ && \ 14 | ln -s /usr/bin/clang-cpp-7 /usr/bin/clang-cpp 15 | -------------------------------------------------------------------------------- /cpp19/lec_06/source/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016-2018 The ISC Authors. 2 | 3 | All rights reserved. 4 | 5 | MIT License 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | -------------------------------------------------------------------------------- /cpp19/lec_06/source/images/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /cpp19/lec_06/source/include/header.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Your Name 2 | 3 | #ifndef INCLUDE_HEADER_HPP_ 4 | #define INCLUDE_HEADER_HPP_ 5 | 6 | #endif // INCLUDE_HEADER_HPP_ 7 | -------------------------------------------------------------------------------- /cpp19/lec_06/source/misc/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp19/lec_06/source/misc/.gitkeep -------------------------------------------------------------------------------- /cpp19/lec_06/source/scripts/checks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | files=`find . -name "*.cpp" -or -name "*.hpp" -or -name ".h" | grep -v "./tools/*"` 5 | filter=-build/c++11,-runtime/references,-whitespace/braces,-whitespace/indent,-whitespace/comments,-build/include_order 6 | echo $files | xargs cpplint --filter=$filter 7 | 8 | export CTEST_OUTPUT_ON_FAILURE=true 9 | # address sanitizer 10 | #CMAKE_LINKER_OPTS="-DCMAKE_EXE_LINKER='-fuse-ld=gold'" 11 | CMAKE_CONFIG_OPTS="-DHUNTER_CONFIGURATION_TYPES=Debug -DCMAKE_BUILD_TYPE=Debug" 12 | CMAKE_TOOLCHAIN_OPTS="-DCMAKE_TOOLCHAIN_FILE='`pwd`/tools/polly/sanitize-address-cxx17-pic.cmake'" 13 | CMAKE_OPTS="$CMAKE_LINKER_OPTS $CMAKE_CONFIG_OPTS $CMAKE_TOOLCHAIN_OPTS" 14 | cmake -H. -B_builds/sanitize-address-cxx17 $CMAKE_OPTS 15 | cmake --build _builds/sanitize-address-cxx17 16 | ./_builds/sanitize-address-cxx17/tests 17 | # thread sanitizer 18 | CMAKE_TOOLCHAIN_OPTS="-DCMAKE_TOOLCHAIN_FILE='`pwd`/tools/polly/sanitize-thread-cxx17-pic.cmake'" 19 | CMAKE_OPTS="$CMAKE_LINKER_OPTS $CMAKE_CONFIG_OPTS $CMAKE_TOOLCHAIN_OPTS" 20 | cmake -H. -B_builds/sanitize-thread-cxx17 $CMAKE_OPTS 21 | cmake --build _builds/sanitize-thread-cxx17 22 | ./_builds/sanitize-thread-cxx17/tests 23 | -------------------------------------------------------------------------------- /cpp19/lec_06/source/scripts/coverage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | export GTEST_COLOR=1 5 | export CTEST_OUTPUT_ON_FAILURE=true 6 | 7 | CMAKE_LINKER_OPTS="-DCMAKE_EXE_LINKER='-fuse-ld=gold'" 8 | CMAKE_CONFIG_OPTS="-DHUNTER_CONFIGURATION_TYPES=Debug -DCMAKE_BUILD_TYPE=Debug" 9 | CMAKE_TOOLCHAIN_OPTS="-DCMAKE_TOOLCHAIN_FILE='`pwd`/tools/polly/gcc-7-cxx17-pic.cmake'" 10 | CMAKE_OPTS="$CMAKE_LINKER_OPTS $CMAKE_CONFIG_OPTS $CMAKE_TOOLCHAIN_OPTS" 11 | 12 | cmake -H. -B_builds $CMAKE_OPTS -DBUILD_COVERAGE=ON 13 | cmake --build _builds 14 | cmake --build _builds --target test 15 | cmake --build _builds --target gcov 16 | cmake --build _builds --target lcov 17 | gcovr -r . 18 | 19 | REPORT_DATA=$(gcovr -r . | base64 | tr -d '\n') 20 | POST_DATA="{\"report\": \"$REPORT_DATA\", \"slug\": \"$TRAVIS_REPO_SLUG\", \"head_branch\": \"$TRAVIS_BRANCH\", \"head_sha\": \"$TRAVIS_COMMIT\"}" 21 | 22 | if [[ $TRAVIS_PULL_REQUEST == 'false' ]]; then 23 | curl -H "Content-Type: application/json" -d "$POST_DATA" -X POST http://borodin.dev.bmstu.cloud/api/coverage/ 24 | fi 25 | -------------------------------------------------------------------------------- /cpp19/lec_06/source/scripts/duplication.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | jscpd --mode "weak" --format "cpp" --ignore "_builds/**" . 6 | 7 | REPORT_DATA=$(jscpd --mode "weak" --format "cpp" --ignore "_builds/**" . | sed -r "s/[[:cntrl:]]\[[0-9]{1,3}m//g" | base64 | tr -d '\n') 8 | POST_DATA="{\"report\": \"$REPORT_DATA\", \"slug\": \"$TRAVIS_REPO_SLUG\", \"head_branch\": \"$TRAVIS_BRANCH\", \"head_sha\": \"$TRAVIS_COMMIT\"}" 9 | 10 | if [[ $TRAVIS_PULL_REQUEST == 'false' ]]; then 11 | curl -H "Content-Type: application/json" -d "$POST_DATA" -X POST http://borodin.dev.bmstu.cloud/api/duplication/ 12 | fi 13 | -------------------------------------------------------------------------------- /cpp19/lec_06/source/scripts/genenv.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | echo "TRAVIS_REPO_SLUG=$TRAVIS_REPO_SLUG" > .env 6 | echo "TRAVIS_PULL_REQUEST=$TRAVIS_PULL_REQUEST" >> .env 7 | echo "TRAVIS_BRANCH=$TRAVIS_BRANCH" >> .env 8 | echo "TRAVIS_COMMIT=$TRAVIS_COMMIT" >> .env -------------------------------------------------------------------------------- /cpp19/lec_06/source/scripts/tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | export GTEST_COLOR=1 4 | CMAKE_LINKER_OPTS="-DCMAKE_EXE_LINKER='-fuse-ld=gold'" 5 | CMAKE_CONFIG_OPTS="-DHUNTER_CONFIGURATION_TYPES=Debug -DCMAKE_BUILD_TYPE=Debug" 6 | CMAKE_TOOLCHAIN_OPTS="-DCMAKE_TOOLCHAIN_FILE='`pwd`/tools/polly/gcc-7-cxx17-pic.cmake'" 7 | CMAKE_OPTS="$CMAKE_LINKER_OPTS $CMAKE_CONFIG_OPTS $CMAKE_TOOLCHAIN_OPTS" 8 | cmake -H. -B_builds $CMAKE_OPTS 9 | cmake --build _builds 10 | cmake --build _builds --target test -- ARGS="--verbose" 11 | -------------------------------------------------------------------------------- /cpp19/lec_06/source/tests/test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Your Name 2 | 3 | #include 4 | 5 | TEST(Example, EmptyTest) { 6 | EXPECT_TRUE(true); 7 | } 8 | -------------------------------------------------------------------------------- /cpp19/lec_06/source/third-party/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/cpp19/lec_06/source/third-party/.gitkeep -------------------------------------------------------------------------------- /cpp19/lec_07/README.md: -------------------------------------------------------------------------------- 1 | 1. Асинхронный Echo-сервер - [async_tcp_echo_server.cpp](https://github.com/boostorg/asio/blob/develop/example/cpp11/echo/async_tcp_echo_server.cpp) 2 | 2. Асинхронный Echo-сервер с использованием сопрограмм - [echo_server.cpp](https://github.com/boostorg/asio/blob/develop/example/cpp17/coroutines_ts/echo_server.cpp) 3 | 3. Упрощенный Echo-сервер - [async_echo.cpp](./async_echo.cpp) 4 | 4. LockFreeStack с учетечками памяти - [lock_free_stack.h](./lock_free_stack.h) 5 | 5. LockFreeStack без учетечками памяти - 6 | -------------------------------------------------------------------------------- /cpp19/lec_07/async_echo.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | using boost::asio::ip::tcp; 9 | 10 | void Echo(std::shared_ptr socket) { 11 | std::shared_ptr> data = 12 | std::make_shared>(1024); 13 | 14 | auto write_callback = [=](boost::system::error_code ec, size_t n) mutable { 15 | Echo(std::move(socket)); 16 | data.reset(); 17 | }; 18 | 19 | auto read_callback = [=](boost::system::error_code ec, size_t n) mutable { 20 | if (!ec) { 21 | socket->async_write_some(boost::asio::buffer(*data, n), write_callback); 22 | } 23 | }; 24 | 25 | socket->async_read_some(boost::asio::buffer(*data), read_callback); 26 | } 27 | 28 | void DoAccept(tcp::acceptor& acceptor, boost::asio::io_service& io_service) { 29 | std::shared_ptr socket = 30 | std::make_shared(io_service); 31 | auto callback = [socket, &acceptor, 32 | &io_service](boost::system::error_code ec) { 33 | Echo(std::move(socket)); 34 | DoAccept(acceptor, io_service); 35 | }; 36 | acceptor.async_accept(*socket, callback); 37 | } 38 | 39 | int main(int argc, char* argv[]) { 40 | try { 41 | boost::asio::io_service io_service; 42 | tcp::acceptor acceptor(io_service, tcp::endpoint(tcp::v4(), 80)); 43 | 44 | DoAccept(acceptor, io_service); 45 | 46 | io_service.run(); 47 | } catch (std::exception& e) { 48 | std::cerr << "Exception: " << e.what() << "\n"; 49 | } 50 | 51 | return 0; 52 | } 53 | -------------------------------------------------------------------------------- /cpp19/lec_07/lock_free_stack.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | template 7 | struct LockFreeStack { 8 | void Push(const T& value) { 9 | Node* new_head = new Node(value, head_.load()); 10 | 11 | while (!head_.compare_exchange_weak(new_head->next, new_head)) { 12 | } 13 | } 14 | 15 | Node* Pop() { 16 | Node* node = head_.load(); 17 | 18 | while (node && !head_.compare_exchange_weak(node, node->next)) { 19 | } 20 | 21 | return node; 22 | } 23 | 24 | private: 25 | struct Node { 26 | T data; 27 | Node* next; 28 | }; 29 | 30 | std::atomic head_; 31 | }; -------------------------------------------------------------------------------- /cpp19/lec_08/source/any.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | 6 | class any { 7 | public: 8 | ~any() { delete data; } 9 | 10 | any() : data(nullptr) {} 11 | 12 | any(const any& rhs) 13 | : data((rhs.data == nullptr) ? nullptr : rhs.data->clone()) {} 14 | 15 | template 16 | any(T v) : data(new Holder(v)) {} 17 | 18 | any(any&& rhs) : data(rhs.data) { rhs.data = nullptr; } 19 | 20 | any& operator=(const any& rhs) { 21 | any(rhs).swap(*this); 22 | return *this; 23 | } 24 | 25 | any& operator=(any&& rhs) { 26 | any(std::move(rhs)).swap(*this); 27 | return *this; 28 | } 29 | 30 | template 31 | any& operator=(T value) { 32 | any(value).swap(*this); 33 | return *this; 34 | } 35 | 36 | any& swap(any& rhs) { 37 | std::swap(this->data, rhs.data); 38 | return *this; 39 | } 40 | 41 | bool has_value() const { return data == nullptr; } 42 | 43 | void reset() { any().swap(*this); } 44 | 45 | struct IPresenter { 46 | virtual IPresenter* clone() const = 0; 47 | virtual const std::type_info& type() = 0; 48 | virtual ~IPresenter() {} 49 | }; 50 | 51 | template 52 | struct Holder : public IPresenter { 53 | Holder(Type v) : value(v) {} 54 | 55 | virtual IPresenter* clone() const override { return new Holder(value); } 56 | 57 | virtual const std::type_info& type() override { return typeid(value); } 58 | 59 | Type value; 60 | }; 61 | 62 | private: 63 | IPresenter* data; 64 | 65 | template 66 | friend T* any_cast(any* op); 67 | }; 68 | 69 | class bad_any_cast : public std::bad_cast { 70 | public: 71 | virtual const char* what() const override { return "bad_any_cast exception"; } 72 | }; 73 | 74 | template 75 | T* any_cast(any* op) { 76 | bool isSame = op->data->type() == typeid(T); 77 | return op && isSame ? &(static_cast*>(op->data)->value) 78 | : nullptr; 79 | } 80 | 81 | template 82 | T* any_cast(const any* op) { 83 | return any_cast(const_cast(op)); 84 | } 85 | 86 | template 87 | inline T any_cast(const any& op) { 88 | auto ptr = any_cast(&op); 89 | 90 | if (ptr == nullptr) throw bad_any_cast(); 91 | 92 | return *ptr; 93 | } -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | title 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 20 | 21 | 24 | 25 | 28 | 29 | 32 | 33 | 36 | 37 | 40 | 41 | 44 | 45 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /docs/lec_01/libs/highlight.js/9.12.0/darcula.css: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Darcula color scheme from the JetBrains family of IDEs 4 | 5 | */ 6 | 7 | 8 | .hljs { 9 | display: block; 10 | overflow-x: auto; 11 | padding: 0.5em; 12 | background: #2b2b2b; 13 | } 14 | 15 | .hljs { 16 | color: #bababa; 17 | } 18 | 19 | .hljs-strong, 20 | .hljs-emphasis { 21 | color: #a8a8a2; 22 | } 23 | 24 | .hljs-bullet, 25 | .hljs-quote, 26 | .hljs-link, 27 | .hljs-number, 28 | .hljs-regexp, 29 | .hljs-literal { 30 | color: #6896ba; 31 | } 32 | 33 | .hljs-code, 34 | .hljs-selector-class { 35 | color: #a6e22e; 36 | } 37 | 38 | .hljs-emphasis { 39 | font-style: italic; 40 | } 41 | 42 | .hljs-keyword, 43 | .hljs-selector-tag, 44 | .hljs-section, 45 | .hljs-attribute, 46 | .hljs-name, 47 | .hljs-variable { 48 | color: #cb7832; 49 | } 50 | 51 | .hljs-params { 52 | color: #b9b9b9; 53 | } 54 | 55 | .hljs-string { 56 | color: #6a8759; 57 | } 58 | 59 | .hljs-subst, 60 | .hljs-type, 61 | .hljs-built_in, 62 | .hljs-builtin-name, 63 | .hljs-symbol, 64 | .hljs-selector-id, 65 | .hljs-selector-attr, 66 | .hljs-selector-pseudo, 67 | .hljs-template-tag, 68 | .hljs-template-variable, 69 | .hljs-addition { 70 | color: #e0c46c; 71 | } 72 | 73 | .hljs-comment, 74 | .hljs-deletion, 75 | .hljs-meta { 76 | color: #7f7f7f; 77 | } 78 | -------------------------------------------------------------------------------- /docs/lec_01/libs/highlight.js/9.12.0/darkula.css: -------------------------------------------------------------------------------- 1 | /* 2 | Deprecated due to a typo in the name and left here for compatibility purpose only. 3 | Please use darcula.css instead. 4 | */ 5 | 6 | @import url('darcula.css'); 7 | -------------------------------------------------------------------------------- /docs/lec_01/libs/reveal.js/3.8.0/plugin/chalkboard/img/blackboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_01/libs/reveal.js/3.8.0/plugin/chalkboard/img/blackboard.png -------------------------------------------------------------------------------- /docs/lec_01/libs/reveal.js/3.8.0/plugin/chalkboard/img/boardmarker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_01/libs/reveal.js/3.8.0/plugin/chalkboard/img/boardmarker.png -------------------------------------------------------------------------------- /docs/lec_01/libs/reveal.js/3.8.0/plugin/chalkboard/img/chalk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_01/libs/reveal.js/3.8.0/plugin/chalkboard/img/chalk.png -------------------------------------------------------------------------------- /docs/lec_01/libs/reveal.js/3.8.0/plugin/chalkboard/img/sponge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_01/libs/reveal.js/3.8.0/plugin/chalkboard/img/sponge.png -------------------------------------------------------------------------------- /docs/lec_01/libs/reveal.js/3.8.0/plugin/embed-tweet/embed-tweet.js: -------------------------------------------------------------------------------- 1 | var RevealEmbedTweet = window.RevealEmbedTweet || (function(){ 2 | var ready = false; 3 | window.twttr = (function(d, s, id) { 4 | var js, fjs = d.getElementsByTagName(s)[0], 5 | t = window.twttr || {}; 6 | if (d.getElementById(id)) return t; 7 | js = d.createElement(s); 8 | js.id = id; 9 | js.src = "https://platform.twitter.com/widgets.js"; 10 | fjs.parentNode.insertBefore(js, fjs); 11 | 12 | t._e = []; 13 | t.ready = function(f) { 14 | t._e.push(f); 15 | }; 16 | }(document, "script", "twitter-wjs")); 17 | 18 | 19 | function load() { 20 | if ( twttr != undefined && !document.querySelector('section[data-markdown]:not([data-markdown-parsed])') ) { 21 | tweets = document.querySelectorAll(".tweet"); 22 | for (i = 0; i < tweets.length; ++i) { 23 | tweets[i].style.cssText = "margin: 0;position: absolute; left: 50%;transform: translate(-50%,0%);" + tweets[i].style.cssText; 24 | tweets[i].innerHTML = ''; 25 | } 26 | twttr.widgets.load() 27 | } 28 | else { 29 | // wait for markdown to be loaded and parsed 30 | setTimeout( load, 100 ); 31 | } 32 | } 33 | 34 | Reveal.addEventListener( 'ready', function( event ) { 35 | load(); 36 | } ); 37 | 38 | 39 | })(); 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /docs/lec_01/libs/reveal.js/font-awesome-4.7.0/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_01/libs/reveal.js/font-awesome-4.7.0/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /docs/lec_01/res/array-java.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_01/res/array-java.png -------------------------------------------------------------------------------- /docs/lec_01/res/chrome-memory-bugs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_01/res/chrome-memory-bugs.png -------------------------------------------------------------------------------- /docs/lec_01/res/data_structs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_01/res/data_structs.png -------------------------------------------------------------------------------- /docs/lec_01/res/hash.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_01/res/hash.jpg -------------------------------------------------------------------------------- /docs/lec_01/res/ids.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_01/res/ids.jpg -------------------------------------------------------------------------------- /docs/lec_01/res/internet-traffic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_01/res/internet-traffic.png -------------------------------------------------------------------------------- /docs/lec_01/res/magistralgor.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_01/res/magistralgor.jpg -------------------------------------------------------------------------------- /docs/lec_01/res/senior.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_01/res/senior.jpg -------------------------------------------------------------------------------- /docs/lec_02/libs/highlight.js/9.12.0/darcula.css: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Darcula color scheme from the JetBrains family of IDEs 4 | 5 | */ 6 | 7 | 8 | .hljs { 9 | display: block; 10 | overflow-x: auto; 11 | padding: 0.5em; 12 | background: #2b2b2b; 13 | } 14 | 15 | .hljs { 16 | color: #bababa; 17 | } 18 | 19 | .hljs-strong, 20 | .hljs-emphasis { 21 | color: #a8a8a2; 22 | } 23 | 24 | .hljs-bullet, 25 | .hljs-quote, 26 | .hljs-link, 27 | .hljs-number, 28 | .hljs-regexp, 29 | .hljs-literal { 30 | color: #6896ba; 31 | } 32 | 33 | .hljs-code, 34 | .hljs-selector-class { 35 | color: #a6e22e; 36 | } 37 | 38 | .hljs-emphasis { 39 | font-style: italic; 40 | } 41 | 42 | .hljs-keyword, 43 | .hljs-selector-tag, 44 | .hljs-section, 45 | .hljs-attribute, 46 | .hljs-name, 47 | .hljs-variable { 48 | color: #cb7832; 49 | } 50 | 51 | .hljs-params { 52 | color: #b9b9b9; 53 | } 54 | 55 | .hljs-string { 56 | color: #6a8759; 57 | } 58 | 59 | .hljs-subst, 60 | .hljs-type, 61 | .hljs-built_in, 62 | .hljs-builtin-name, 63 | .hljs-symbol, 64 | .hljs-selector-id, 65 | .hljs-selector-attr, 66 | .hljs-selector-pseudo, 67 | .hljs-template-tag, 68 | .hljs-template-variable, 69 | .hljs-addition { 70 | color: #e0c46c; 71 | } 72 | 73 | .hljs-comment, 74 | .hljs-deletion, 75 | .hljs-meta { 76 | color: #7f7f7f; 77 | } 78 | -------------------------------------------------------------------------------- /docs/lec_02/libs/highlight.js/9.12.0/darkula.css: -------------------------------------------------------------------------------- 1 | /* 2 | Deprecated due to a typo in the name and left here for compatibility purpose only. 3 | Please use darcula.css instead. 4 | */ 5 | 6 | @import url('darcula.css'); 7 | -------------------------------------------------------------------------------- /docs/lec_02/libs/reveal.js/3.8.0/plugin/chalkboard/img/blackboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_02/libs/reveal.js/3.8.0/plugin/chalkboard/img/blackboard.png -------------------------------------------------------------------------------- /docs/lec_02/libs/reveal.js/3.8.0/plugin/chalkboard/img/boardmarker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_02/libs/reveal.js/3.8.0/plugin/chalkboard/img/boardmarker.png -------------------------------------------------------------------------------- /docs/lec_02/libs/reveal.js/3.8.0/plugin/chalkboard/img/chalk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_02/libs/reveal.js/3.8.0/plugin/chalkboard/img/chalk.png -------------------------------------------------------------------------------- /docs/lec_02/libs/reveal.js/3.8.0/plugin/chalkboard/img/sponge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_02/libs/reveal.js/3.8.0/plugin/chalkboard/img/sponge.png -------------------------------------------------------------------------------- /docs/lec_02/libs/reveal.js/3.8.0/plugin/embed-tweet/embed-tweet.js: -------------------------------------------------------------------------------- 1 | var RevealEmbedTweet = window.RevealEmbedTweet || (function(){ 2 | var ready = false; 3 | window.twttr = (function(d, s, id) { 4 | var js, fjs = d.getElementsByTagName(s)[0], 5 | t = window.twttr || {}; 6 | if (d.getElementById(id)) return t; 7 | js = d.createElement(s); 8 | js.id = id; 9 | js.src = "https://platform.twitter.com/widgets.js"; 10 | fjs.parentNode.insertBefore(js, fjs); 11 | 12 | t._e = []; 13 | t.ready = function(f) { 14 | t._e.push(f); 15 | }; 16 | }(document, "script", "twitter-wjs")); 17 | 18 | 19 | function load() { 20 | if ( twttr != undefined && !document.querySelector('section[data-markdown]:not([data-markdown-parsed])') ) { 21 | tweets = document.querySelectorAll(".tweet"); 22 | for (i = 0; i < tweets.length; ++i) { 23 | tweets[i].style.cssText = "margin: 0;position: absolute; left: 50%;transform: translate(-50%,0%);" + tweets[i].style.cssText; 24 | tweets[i].innerHTML = ''; 25 | } 26 | twttr.widgets.load() 27 | } 28 | else { 29 | // wait for markdown to be loaded and parsed 30 | setTimeout( load, 100 ); 31 | } 32 | } 33 | 34 | Reveal.addEventListener( 'ready', function( event ) { 35 | load(); 36 | } ); 37 | 38 | 39 | })(); 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /docs/lec_02/libs/reveal.js/font-awesome-4.7.0/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_02/libs/reveal.js/font-awesome-4.7.0/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /docs/lec_02/res/pointers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_02/res/pointers.png -------------------------------------------------------------------------------- /docs/lec_02/res/shared.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_02/res/shared.png -------------------------------------------------------------------------------- /docs/lec_03/libs/highlight.js/9.12.0/darcula.css: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Darcula color scheme from the JetBrains family of IDEs 4 | 5 | */ 6 | 7 | 8 | .hljs { 9 | display: block; 10 | overflow-x: auto; 11 | padding: 0.5em; 12 | background: #2b2b2b; 13 | } 14 | 15 | .hljs { 16 | color: #bababa; 17 | } 18 | 19 | .hljs-strong, 20 | .hljs-emphasis { 21 | color: #a8a8a2; 22 | } 23 | 24 | .hljs-bullet, 25 | .hljs-quote, 26 | .hljs-link, 27 | .hljs-number, 28 | .hljs-regexp, 29 | .hljs-literal { 30 | color: #6896ba; 31 | } 32 | 33 | .hljs-code, 34 | .hljs-selector-class { 35 | color: #a6e22e; 36 | } 37 | 38 | .hljs-emphasis { 39 | font-style: italic; 40 | } 41 | 42 | .hljs-keyword, 43 | .hljs-selector-tag, 44 | .hljs-section, 45 | .hljs-attribute, 46 | .hljs-name, 47 | .hljs-variable { 48 | color: #cb7832; 49 | } 50 | 51 | .hljs-params { 52 | color: #b9b9b9; 53 | } 54 | 55 | .hljs-string { 56 | color: #6a8759; 57 | } 58 | 59 | .hljs-subst, 60 | .hljs-type, 61 | .hljs-built_in, 62 | .hljs-builtin-name, 63 | .hljs-symbol, 64 | .hljs-selector-id, 65 | .hljs-selector-attr, 66 | .hljs-selector-pseudo, 67 | .hljs-template-tag, 68 | .hljs-template-variable, 69 | .hljs-addition { 70 | color: #e0c46c; 71 | } 72 | 73 | .hljs-comment, 74 | .hljs-deletion, 75 | .hljs-meta { 76 | color: #7f7f7f; 77 | } 78 | -------------------------------------------------------------------------------- /docs/lec_03/libs/highlight.js/9.12.0/darkula.css: -------------------------------------------------------------------------------- 1 | /* 2 | Deprecated due to a typo in the name and left here for compatibility purpose only. 3 | Please use darcula.css instead. 4 | */ 5 | 6 | @import url('darcula.css'); 7 | -------------------------------------------------------------------------------- /docs/lec_03/libs/reveal.js/3.8.0/plugin/chalkboard/img/blackboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_03/libs/reveal.js/3.8.0/plugin/chalkboard/img/blackboard.png -------------------------------------------------------------------------------- /docs/lec_03/libs/reveal.js/3.8.0/plugin/chalkboard/img/boardmarker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_03/libs/reveal.js/3.8.0/plugin/chalkboard/img/boardmarker.png -------------------------------------------------------------------------------- /docs/lec_03/libs/reveal.js/3.8.0/plugin/chalkboard/img/chalk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_03/libs/reveal.js/3.8.0/plugin/chalkboard/img/chalk.png -------------------------------------------------------------------------------- /docs/lec_03/libs/reveal.js/3.8.0/plugin/chalkboard/img/sponge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_03/libs/reveal.js/3.8.0/plugin/chalkboard/img/sponge.png -------------------------------------------------------------------------------- /docs/lec_03/libs/reveal.js/3.8.0/plugin/embed-tweet/embed-tweet.js: -------------------------------------------------------------------------------- 1 | var RevealEmbedTweet = window.RevealEmbedTweet || (function(){ 2 | var ready = false; 3 | window.twttr = (function(d, s, id) { 4 | var js, fjs = d.getElementsByTagName(s)[0], 5 | t = window.twttr || {}; 6 | if (d.getElementById(id)) return t; 7 | js = d.createElement(s); 8 | js.id = id; 9 | js.src = "https://platform.twitter.com/widgets.js"; 10 | fjs.parentNode.insertBefore(js, fjs); 11 | 12 | t._e = []; 13 | t.ready = function(f) { 14 | t._e.push(f); 15 | }; 16 | }(document, "script", "twitter-wjs")); 17 | 18 | 19 | function load() { 20 | if ( twttr != undefined && !document.querySelector('section[data-markdown]:not([data-markdown-parsed])') ) { 21 | tweets = document.querySelectorAll(".tweet"); 22 | for (i = 0; i < tweets.length; ++i) { 23 | tweets[i].style.cssText = "margin: 0;position: absolute; left: 50%;transform: translate(-50%,0%);" + tweets[i].style.cssText; 24 | tweets[i].innerHTML = ''; 25 | } 26 | twttr.widgets.load() 27 | } 28 | else { 29 | // wait for markdown to be loaded and parsed 30 | setTimeout( load, 100 ); 31 | } 32 | } 33 | 34 | Reveal.addEventListener( 'ready', function( event ) { 35 | load(); 36 | } ); 37 | 38 | 39 | })(); 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /docs/lec_03/libs/reveal.js/font-awesome-4.7.0/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_03/libs/reveal.js/font-awesome-4.7.0/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /docs/lec_03/res/go-deeper.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_03/res/go-deeper.jpg -------------------------------------------------------------------------------- /docs/lec_03/res/shared.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_03/res/shared.png -------------------------------------------------------------------------------- /docs/lec_04/libs/highlight.js/9.12.0/darcula.css: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Darcula color scheme from the JetBrains family of IDEs 4 | 5 | */ 6 | 7 | 8 | .hljs { 9 | display: block; 10 | overflow-x: auto; 11 | padding: 0.5em; 12 | background: #2b2b2b; 13 | } 14 | 15 | .hljs { 16 | color: #bababa; 17 | } 18 | 19 | .hljs-strong, 20 | .hljs-emphasis { 21 | color: #a8a8a2; 22 | } 23 | 24 | .hljs-bullet, 25 | .hljs-quote, 26 | .hljs-link, 27 | .hljs-number, 28 | .hljs-regexp, 29 | .hljs-literal { 30 | color: #6896ba; 31 | } 32 | 33 | .hljs-code, 34 | .hljs-selector-class { 35 | color: #a6e22e; 36 | } 37 | 38 | .hljs-emphasis { 39 | font-style: italic; 40 | } 41 | 42 | .hljs-keyword, 43 | .hljs-selector-tag, 44 | .hljs-section, 45 | .hljs-attribute, 46 | .hljs-name, 47 | .hljs-variable { 48 | color: #cb7832; 49 | } 50 | 51 | .hljs-params { 52 | color: #b9b9b9; 53 | } 54 | 55 | .hljs-string { 56 | color: #6a8759; 57 | } 58 | 59 | .hljs-subst, 60 | .hljs-type, 61 | .hljs-built_in, 62 | .hljs-builtin-name, 63 | .hljs-symbol, 64 | .hljs-selector-id, 65 | .hljs-selector-attr, 66 | .hljs-selector-pseudo, 67 | .hljs-template-tag, 68 | .hljs-template-variable, 69 | .hljs-addition { 70 | color: #e0c46c; 71 | } 72 | 73 | .hljs-comment, 74 | .hljs-deletion, 75 | .hljs-meta { 76 | color: #7f7f7f; 77 | } 78 | -------------------------------------------------------------------------------- /docs/lec_04/libs/highlight.js/9.12.0/darkula.css: -------------------------------------------------------------------------------- 1 | /* 2 | Deprecated due to a typo in the name and left here for compatibility purpose only. 3 | Please use darcula.css instead. 4 | */ 5 | 6 | @import url('darcula.css'); 7 | -------------------------------------------------------------------------------- /docs/lec_04/libs/reveal.js/3.8.0/plugin/chalkboard/img/blackboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_04/libs/reveal.js/3.8.0/plugin/chalkboard/img/blackboard.png -------------------------------------------------------------------------------- /docs/lec_04/libs/reveal.js/3.8.0/plugin/chalkboard/img/boardmarker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_04/libs/reveal.js/3.8.0/plugin/chalkboard/img/boardmarker.png -------------------------------------------------------------------------------- /docs/lec_04/libs/reveal.js/3.8.0/plugin/chalkboard/img/chalk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_04/libs/reveal.js/3.8.0/plugin/chalkboard/img/chalk.png -------------------------------------------------------------------------------- /docs/lec_04/libs/reveal.js/3.8.0/plugin/chalkboard/img/sponge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_04/libs/reveal.js/3.8.0/plugin/chalkboard/img/sponge.png -------------------------------------------------------------------------------- /docs/lec_04/libs/reveal.js/3.8.0/plugin/embed-tweet/embed-tweet.js: -------------------------------------------------------------------------------- 1 | var RevealEmbedTweet = window.RevealEmbedTweet || (function(){ 2 | var ready = false; 3 | window.twttr = (function(d, s, id) { 4 | var js, fjs = d.getElementsByTagName(s)[0], 5 | t = window.twttr || {}; 6 | if (d.getElementById(id)) return t; 7 | js = d.createElement(s); 8 | js.id = id; 9 | js.src = "https://platform.twitter.com/widgets.js"; 10 | fjs.parentNode.insertBefore(js, fjs); 11 | 12 | t._e = []; 13 | t.ready = function(f) { 14 | t._e.push(f); 15 | }; 16 | }(document, "script", "twitter-wjs")); 17 | 18 | 19 | function load() { 20 | if ( twttr != undefined && !document.querySelector('section[data-markdown]:not([data-markdown-parsed])') ) { 21 | tweets = document.querySelectorAll(".tweet"); 22 | for (i = 0; i < tweets.length; ++i) { 23 | tweets[i].style.cssText = "margin: 0;position: absolute; left: 50%;transform: translate(-50%,0%);" + tweets[i].style.cssText; 24 | tweets[i].innerHTML = ''; 25 | } 26 | twttr.widgets.load() 27 | } 28 | else { 29 | // wait for markdown to be loaded and parsed 30 | setTimeout( load, 100 ); 31 | } 32 | } 33 | 34 | Reveal.addEventListener( 'ready', function( event ) { 35 | load(); 36 | } ); 37 | 38 | 39 | })(); 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /docs/lec_04/libs/reveal.js/font-awesome-4.7.0/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_04/libs/reveal.js/font-awesome-4.7.0/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /docs/lec_04/res/cores.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_04/res/cores.jpg -------------------------------------------------------------------------------- /docs/lec_04/res/multitask2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_04/res/multitask2.jpg -------------------------------------------------------------------------------- /docs/lec_05/libs/highlight.js/9.12.0/darcula.css: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Darcula color scheme from the JetBrains family of IDEs 4 | 5 | */ 6 | 7 | 8 | .hljs { 9 | display: block; 10 | overflow-x: auto; 11 | padding: 0.5em; 12 | background: #2b2b2b; 13 | } 14 | 15 | .hljs { 16 | color: #bababa; 17 | } 18 | 19 | .hljs-strong, 20 | .hljs-emphasis { 21 | color: #a8a8a2; 22 | } 23 | 24 | .hljs-bullet, 25 | .hljs-quote, 26 | .hljs-link, 27 | .hljs-number, 28 | .hljs-regexp, 29 | .hljs-literal { 30 | color: #6896ba; 31 | } 32 | 33 | .hljs-code, 34 | .hljs-selector-class { 35 | color: #a6e22e; 36 | } 37 | 38 | .hljs-emphasis { 39 | font-style: italic; 40 | } 41 | 42 | .hljs-keyword, 43 | .hljs-selector-tag, 44 | .hljs-section, 45 | .hljs-attribute, 46 | .hljs-name, 47 | .hljs-variable { 48 | color: #cb7832; 49 | } 50 | 51 | .hljs-params { 52 | color: #b9b9b9; 53 | } 54 | 55 | .hljs-string { 56 | color: #6a8759; 57 | } 58 | 59 | .hljs-subst, 60 | .hljs-type, 61 | .hljs-built_in, 62 | .hljs-builtin-name, 63 | .hljs-symbol, 64 | .hljs-selector-id, 65 | .hljs-selector-attr, 66 | .hljs-selector-pseudo, 67 | .hljs-template-tag, 68 | .hljs-template-variable, 69 | .hljs-addition { 70 | color: #e0c46c; 71 | } 72 | 73 | .hljs-comment, 74 | .hljs-deletion, 75 | .hljs-meta { 76 | color: #7f7f7f; 77 | } 78 | -------------------------------------------------------------------------------- /docs/lec_05/libs/highlight.js/9.12.0/darkula.css: -------------------------------------------------------------------------------- 1 | /* 2 | Deprecated due to a typo in the name and left here for compatibility purpose only. 3 | Please use darcula.css instead. 4 | */ 5 | 6 | @import url('darcula.css'); 7 | -------------------------------------------------------------------------------- /docs/lec_05/libs/reveal.js/3.8.0/plugin/chalkboard/img/blackboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_05/libs/reveal.js/3.8.0/plugin/chalkboard/img/blackboard.png -------------------------------------------------------------------------------- /docs/lec_05/libs/reveal.js/3.8.0/plugin/chalkboard/img/boardmarker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_05/libs/reveal.js/3.8.0/plugin/chalkboard/img/boardmarker.png -------------------------------------------------------------------------------- /docs/lec_05/libs/reveal.js/3.8.0/plugin/chalkboard/img/chalk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_05/libs/reveal.js/3.8.0/plugin/chalkboard/img/chalk.png -------------------------------------------------------------------------------- /docs/lec_05/libs/reveal.js/3.8.0/plugin/chalkboard/img/sponge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_05/libs/reveal.js/3.8.0/plugin/chalkboard/img/sponge.png -------------------------------------------------------------------------------- /docs/lec_05/libs/reveal.js/3.8.0/plugin/embed-tweet/embed-tweet.js: -------------------------------------------------------------------------------- 1 | var RevealEmbedTweet = window.RevealEmbedTweet || (function(){ 2 | var ready = false; 3 | window.twttr = (function(d, s, id) { 4 | var js, fjs = d.getElementsByTagName(s)[0], 5 | t = window.twttr || {}; 6 | if (d.getElementById(id)) return t; 7 | js = d.createElement(s); 8 | js.id = id; 9 | js.src = "https://platform.twitter.com/widgets.js"; 10 | fjs.parentNode.insertBefore(js, fjs); 11 | 12 | t._e = []; 13 | t.ready = function(f) { 14 | t._e.push(f); 15 | }; 16 | }(document, "script", "twitter-wjs")); 17 | 18 | 19 | function load() { 20 | if ( twttr != undefined && !document.querySelector('section[data-markdown]:not([data-markdown-parsed])') ) { 21 | tweets = document.querySelectorAll(".tweet"); 22 | for (i = 0; i < tweets.length; ++i) { 23 | tweets[i].style.cssText = "margin: 0;position: absolute; left: 50%;transform: translate(-50%,0%);" + tweets[i].style.cssText; 24 | tweets[i].innerHTML = ''; 25 | } 26 | twttr.widgets.load() 27 | } 28 | else { 29 | // wait for markdown to be loaded and parsed 30 | setTimeout( load, 100 ); 31 | } 32 | } 33 | 34 | Reveal.addEventListener( 'ready', function( event ) { 35 | load(); 36 | } ); 37 | 38 | 39 | })(); 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /docs/lec_05/libs/reveal.js/font-awesome-4.7.0/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_05/libs/reveal.js/font-awesome-4.7.0/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /docs/lec_05/res/li.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_05/res/li.png -------------------------------------------------------------------------------- /docs/lec_05/res/osi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_05/res/osi.png -------------------------------------------------------------------------------- /docs/lec_05/res/socket_functions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_05/res/socket_functions.png -------------------------------------------------------------------------------- /docs/lec_05/res/spiderweb-corner-right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_05/res/spiderweb-corner-right.png -------------------------------------------------------------------------------- /docs/lec_05/res/tcp_ip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_05/res/tcp_ip.png -------------------------------------------------------------------------------- /docs/lec_05/res/tcp_ip_osi.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_05/res/tcp_ip_osi.jpg -------------------------------------------------------------------------------- /docs/lec_06/libs/highlight.js/9.12.0/darcula.css: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Darcula color scheme from the JetBrains family of IDEs 4 | 5 | */ 6 | 7 | 8 | .hljs { 9 | display: block; 10 | overflow-x: auto; 11 | padding: 0.5em; 12 | background: #2b2b2b; 13 | } 14 | 15 | .hljs { 16 | color: #bababa; 17 | } 18 | 19 | .hljs-strong, 20 | .hljs-emphasis { 21 | color: #a8a8a2; 22 | } 23 | 24 | .hljs-bullet, 25 | .hljs-quote, 26 | .hljs-link, 27 | .hljs-number, 28 | .hljs-regexp, 29 | .hljs-literal { 30 | color: #6896ba; 31 | } 32 | 33 | .hljs-code, 34 | .hljs-selector-class { 35 | color: #a6e22e; 36 | } 37 | 38 | .hljs-emphasis { 39 | font-style: italic; 40 | } 41 | 42 | .hljs-keyword, 43 | .hljs-selector-tag, 44 | .hljs-section, 45 | .hljs-attribute, 46 | .hljs-name, 47 | .hljs-variable { 48 | color: #cb7832; 49 | } 50 | 51 | .hljs-params { 52 | color: #b9b9b9; 53 | } 54 | 55 | .hljs-string { 56 | color: #6a8759; 57 | } 58 | 59 | .hljs-subst, 60 | .hljs-type, 61 | .hljs-built_in, 62 | .hljs-builtin-name, 63 | .hljs-symbol, 64 | .hljs-selector-id, 65 | .hljs-selector-attr, 66 | .hljs-selector-pseudo, 67 | .hljs-template-tag, 68 | .hljs-template-variable, 69 | .hljs-addition { 70 | color: #e0c46c; 71 | } 72 | 73 | .hljs-comment, 74 | .hljs-deletion, 75 | .hljs-meta { 76 | color: #7f7f7f; 77 | } 78 | -------------------------------------------------------------------------------- /docs/lec_06/libs/highlight.js/9.12.0/darkula.css: -------------------------------------------------------------------------------- 1 | /* 2 | Deprecated due to a typo in the name and left here for compatibility purpose only. 3 | Please use darcula.css instead. 4 | */ 5 | 6 | @import url('darcula.css'); 7 | -------------------------------------------------------------------------------- /docs/lec_06/libs/reveal.js/3.8.0/plugin/chalkboard/img/blackboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_06/libs/reveal.js/3.8.0/plugin/chalkboard/img/blackboard.png -------------------------------------------------------------------------------- /docs/lec_06/libs/reveal.js/3.8.0/plugin/chalkboard/img/boardmarker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_06/libs/reveal.js/3.8.0/plugin/chalkboard/img/boardmarker.png -------------------------------------------------------------------------------- /docs/lec_06/libs/reveal.js/3.8.0/plugin/chalkboard/img/chalk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_06/libs/reveal.js/3.8.0/plugin/chalkboard/img/chalk.png -------------------------------------------------------------------------------- /docs/lec_06/libs/reveal.js/3.8.0/plugin/chalkboard/img/sponge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_06/libs/reveal.js/3.8.0/plugin/chalkboard/img/sponge.png -------------------------------------------------------------------------------- /docs/lec_06/libs/reveal.js/3.8.0/plugin/embed-tweet/embed-tweet.js: -------------------------------------------------------------------------------- 1 | var RevealEmbedTweet = window.RevealEmbedTweet || (function(){ 2 | var ready = false; 3 | window.twttr = (function(d, s, id) { 4 | var js, fjs = d.getElementsByTagName(s)[0], 5 | t = window.twttr || {}; 6 | if (d.getElementById(id)) return t; 7 | js = d.createElement(s); 8 | js.id = id; 9 | js.src = "https://platform.twitter.com/widgets.js"; 10 | fjs.parentNode.insertBefore(js, fjs); 11 | 12 | t._e = []; 13 | t.ready = function(f) { 14 | t._e.push(f); 15 | }; 16 | }(document, "script", "twitter-wjs")); 17 | 18 | 19 | function load() { 20 | if ( twttr != undefined && !document.querySelector('section[data-markdown]:not([data-markdown-parsed])') ) { 21 | tweets = document.querySelectorAll(".tweet"); 22 | for (i = 0; i < tweets.length; ++i) { 23 | tweets[i].style.cssText = "margin: 0;position: absolute; left: 50%;transform: translate(-50%,0%);" + tweets[i].style.cssText; 24 | tweets[i].innerHTML = ''; 25 | } 26 | twttr.widgets.load() 27 | } 28 | else { 29 | // wait for markdown to be loaded and parsed 30 | setTimeout( load, 100 ); 31 | } 32 | } 33 | 34 | Reveal.addEventListener( 'ready', function( event ) { 35 | load(); 36 | } ); 37 | 38 | 39 | })(); 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /docs/lec_06/libs/reveal.js/font-awesome-4.7.0/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_06/libs/reveal.js/font-awesome-4.7.0/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /docs/lec_06/res/deadlock_hire.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_06/res/deadlock_hire.jpg -------------------------------------------------------------------------------- /docs/lec_06/res/fet.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_06/res/fet.jpg -------------------------------------------------------------------------------- /docs/lec_06/res/lermontov.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_06/res/lermontov.jpg -------------------------------------------------------------------------------- /docs/lec_06/res/paper.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_06/res/paper.jpg -------------------------------------------------------------------------------- /docs/lec_06/res/pero.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_06/res/pero.jpg -------------------------------------------------------------------------------- /docs/lec_06/res/pushkin.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_06/res/pushkin.jpg -------------------------------------------------------------------------------- /docs/lec_06/res/sync.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_06/res/sync.mp4 -------------------------------------------------------------------------------- /docs/lec_07/libs/highlight.js/9.12.0/darcula.css: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Darcula color scheme from the JetBrains family of IDEs 4 | 5 | */ 6 | 7 | 8 | .hljs { 9 | display: block; 10 | overflow-x: auto; 11 | padding: 0.5em; 12 | background: #2b2b2b; 13 | } 14 | 15 | .hljs { 16 | color: #bababa; 17 | } 18 | 19 | .hljs-strong, 20 | .hljs-emphasis { 21 | color: #a8a8a2; 22 | } 23 | 24 | .hljs-bullet, 25 | .hljs-quote, 26 | .hljs-link, 27 | .hljs-number, 28 | .hljs-regexp, 29 | .hljs-literal { 30 | color: #6896ba; 31 | } 32 | 33 | .hljs-code, 34 | .hljs-selector-class { 35 | color: #a6e22e; 36 | } 37 | 38 | .hljs-emphasis { 39 | font-style: italic; 40 | } 41 | 42 | .hljs-keyword, 43 | .hljs-selector-tag, 44 | .hljs-section, 45 | .hljs-attribute, 46 | .hljs-name, 47 | .hljs-variable { 48 | color: #cb7832; 49 | } 50 | 51 | .hljs-params { 52 | color: #b9b9b9; 53 | } 54 | 55 | .hljs-string { 56 | color: #6a8759; 57 | } 58 | 59 | .hljs-subst, 60 | .hljs-type, 61 | .hljs-built_in, 62 | .hljs-builtin-name, 63 | .hljs-symbol, 64 | .hljs-selector-id, 65 | .hljs-selector-attr, 66 | .hljs-selector-pseudo, 67 | .hljs-template-tag, 68 | .hljs-template-variable, 69 | .hljs-addition { 70 | color: #e0c46c; 71 | } 72 | 73 | .hljs-comment, 74 | .hljs-deletion, 75 | .hljs-meta { 76 | color: #7f7f7f; 77 | } 78 | -------------------------------------------------------------------------------- /docs/lec_07/libs/highlight.js/9.12.0/darkula.css: -------------------------------------------------------------------------------- 1 | /* 2 | Deprecated due to a typo in the name and left here for compatibility purpose only. 3 | Please use darcula.css instead. 4 | */ 5 | 6 | @import url('darcula.css'); 7 | -------------------------------------------------------------------------------- /docs/lec_07/libs/reveal.js/3.8.0/plugin/chalkboard/img/blackboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_07/libs/reveal.js/3.8.0/plugin/chalkboard/img/blackboard.png -------------------------------------------------------------------------------- /docs/lec_07/libs/reveal.js/3.8.0/plugin/chalkboard/img/boardmarker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_07/libs/reveal.js/3.8.0/plugin/chalkboard/img/boardmarker.png -------------------------------------------------------------------------------- /docs/lec_07/libs/reveal.js/3.8.0/plugin/chalkboard/img/chalk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_07/libs/reveal.js/3.8.0/plugin/chalkboard/img/chalk.png -------------------------------------------------------------------------------- /docs/lec_07/libs/reveal.js/3.8.0/plugin/chalkboard/img/sponge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_07/libs/reveal.js/3.8.0/plugin/chalkboard/img/sponge.png -------------------------------------------------------------------------------- /docs/lec_07/libs/reveal.js/3.8.0/plugin/embed-tweet/embed-tweet.js: -------------------------------------------------------------------------------- 1 | var RevealEmbedTweet = window.RevealEmbedTweet || (function(){ 2 | var ready = false; 3 | window.twttr = (function(d, s, id) { 4 | var js, fjs = d.getElementsByTagName(s)[0], 5 | t = window.twttr || {}; 6 | if (d.getElementById(id)) return t; 7 | js = d.createElement(s); 8 | js.id = id; 9 | js.src = "https://platform.twitter.com/widgets.js"; 10 | fjs.parentNode.insertBefore(js, fjs); 11 | 12 | t._e = []; 13 | t.ready = function(f) { 14 | t._e.push(f); 15 | }; 16 | }(document, "script", "twitter-wjs")); 17 | 18 | 19 | function load() { 20 | if ( twttr != undefined && !document.querySelector('section[data-markdown]:not([data-markdown-parsed])') ) { 21 | tweets = document.querySelectorAll(".tweet"); 22 | for (i = 0; i < tweets.length; ++i) { 23 | tweets[i].style.cssText = "margin: 0;position: absolute; left: 50%;transform: translate(-50%,0%);" + tweets[i].style.cssText; 24 | tweets[i].innerHTML = ''; 25 | } 26 | twttr.widgets.load() 27 | } 28 | else { 29 | // wait for markdown to be loaded and parsed 30 | setTimeout( load, 100 ); 31 | } 32 | } 33 | 34 | Reveal.addEventListener( 'ready', function( event ) { 35 | load(); 36 | } ); 37 | 38 | 39 | })(); 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /docs/lec_07/libs/reveal.js/font-awesome-4.7.0/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_07/libs/reveal.js/font-awesome-4.7.0/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /docs/lec_07/res/ThreadPool.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_07/res/ThreadPool.png -------------------------------------------------------------------------------- /docs/lec_07/res/multitask2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_07/res/multitask2.jpg -------------------------------------------------------------------------------- /docs/lec_07/res/oven.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_07/res/oven.jpg -------------------------------------------------------------------------------- /docs/lec_07/res/oven_callback.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_07/res/oven_callback.jpg -------------------------------------------------------------------------------- /docs/lec_07/res/pan.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_07/res/pan.jpg -------------------------------------------------------------------------------- /docs/lec_07/res/queue.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_07/res/queue.jpg -------------------------------------------------------------------------------- /docs/lec_08/libs/highlight.js/9.12.0/darcula.css: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Darcula color scheme from the JetBrains family of IDEs 4 | 5 | */ 6 | 7 | 8 | .hljs { 9 | display: block; 10 | overflow-x: auto; 11 | padding: 0.5em; 12 | background: #2b2b2b; 13 | } 14 | 15 | .hljs { 16 | color: #bababa; 17 | } 18 | 19 | .hljs-strong, 20 | .hljs-emphasis { 21 | color: #a8a8a2; 22 | } 23 | 24 | .hljs-bullet, 25 | .hljs-quote, 26 | .hljs-link, 27 | .hljs-number, 28 | .hljs-regexp, 29 | .hljs-literal { 30 | color: #6896ba; 31 | } 32 | 33 | .hljs-code, 34 | .hljs-selector-class { 35 | color: #a6e22e; 36 | } 37 | 38 | .hljs-emphasis { 39 | font-style: italic; 40 | } 41 | 42 | .hljs-keyword, 43 | .hljs-selector-tag, 44 | .hljs-section, 45 | .hljs-attribute, 46 | .hljs-name, 47 | .hljs-variable { 48 | color: #cb7832; 49 | } 50 | 51 | .hljs-params { 52 | color: #b9b9b9; 53 | } 54 | 55 | .hljs-string { 56 | color: #6a8759; 57 | } 58 | 59 | .hljs-subst, 60 | .hljs-type, 61 | .hljs-built_in, 62 | .hljs-builtin-name, 63 | .hljs-symbol, 64 | .hljs-selector-id, 65 | .hljs-selector-attr, 66 | .hljs-selector-pseudo, 67 | .hljs-template-tag, 68 | .hljs-template-variable, 69 | .hljs-addition { 70 | color: #e0c46c; 71 | } 72 | 73 | .hljs-comment, 74 | .hljs-deletion, 75 | .hljs-meta { 76 | color: #7f7f7f; 77 | } 78 | -------------------------------------------------------------------------------- /docs/lec_08/libs/highlight.js/9.12.0/darkula.css: -------------------------------------------------------------------------------- 1 | /* 2 | Deprecated due to a typo in the name and left here for compatibility purpose only. 3 | Please use darcula.css instead. 4 | */ 5 | 6 | @import url('darcula.css'); 7 | -------------------------------------------------------------------------------- /docs/lec_08/libs/reveal.js/3.8.0/plugin/chalkboard/img/blackboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_08/libs/reveal.js/3.8.0/plugin/chalkboard/img/blackboard.png -------------------------------------------------------------------------------- /docs/lec_08/libs/reveal.js/3.8.0/plugin/chalkboard/img/boardmarker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_08/libs/reveal.js/3.8.0/plugin/chalkboard/img/boardmarker.png -------------------------------------------------------------------------------- /docs/lec_08/libs/reveal.js/3.8.0/plugin/chalkboard/img/chalk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_08/libs/reveal.js/3.8.0/plugin/chalkboard/img/chalk.png -------------------------------------------------------------------------------- /docs/lec_08/libs/reveal.js/3.8.0/plugin/chalkboard/img/sponge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_08/libs/reveal.js/3.8.0/plugin/chalkboard/img/sponge.png -------------------------------------------------------------------------------- /docs/lec_08/libs/reveal.js/3.8.0/plugin/embed-tweet/embed-tweet.js: -------------------------------------------------------------------------------- 1 | var RevealEmbedTweet = window.RevealEmbedTweet || (function(){ 2 | var ready = false; 3 | window.twttr = (function(d, s, id) { 4 | var js, fjs = d.getElementsByTagName(s)[0], 5 | t = window.twttr || {}; 6 | if (d.getElementById(id)) return t; 7 | js = d.createElement(s); 8 | js.id = id; 9 | js.src = "https://platform.twitter.com/widgets.js"; 10 | fjs.parentNode.insertBefore(js, fjs); 11 | 12 | t._e = []; 13 | t.ready = function(f) { 14 | t._e.push(f); 15 | }; 16 | }(document, "script", "twitter-wjs")); 17 | 18 | 19 | function load() { 20 | if ( twttr != undefined && !document.querySelector('section[data-markdown]:not([data-markdown-parsed])') ) { 21 | tweets = document.querySelectorAll(".tweet"); 22 | for (i = 0; i < tweets.length; ++i) { 23 | tweets[i].style.cssText = "margin: 0;position: absolute; left: 50%;transform: translate(-50%,0%);" + tweets[i].style.cssText; 24 | tweets[i].innerHTML = ''; 25 | } 26 | twttr.widgets.load() 27 | } 28 | else { 29 | // wait for markdown to be loaded and parsed 30 | setTimeout( load, 100 ); 31 | } 32 | } 33 | 34 | Reveal.addEventListener( 'ready', function( event ) { 35 | load(); 36 | } ); 37 | 38 | 39 | })(); 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /docs/lec_08/libs/reveal.js/font-awesome-4.7.0/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_08/libs/reveal.js/font-awesome-4.7.0/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /docs/lec_08/res/storage_add_block.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_08/res/storage_add_block.png -------------------------------------------------------------------------------- /docs/lec_08/res/storage_after_free.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_08/res/storage_after_free.png -------------------------------------------------------------------------------- /docs/lec_08/res/storage_after_free2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_08/res/storage_after_free2.png -------------------------------------------------------------------------------- /docs/lec_08/res/storage_after_malloc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_08/res/storage_after_malloc.png -------------------------------------------------------------------------------- /docs/lec_08/res/storage_after_malloc2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_08/res/storage_after_malloc2.png -------------------------------------------------------------------------------- /docs/lec_08/res/stupid_pool.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bmstu-iu8-cpp/cpp-upper-intermediate/8e796c219c4f90c433290c13880f6b8e99c53ee0/docs/lec_08/res/stupid_pool.png --------------------------------------------------------------------------------