Download materials for Bisqwit's C++14 thread tutorial

Auxiliary to: https://www.youtube.com/watch?v=_z-RS0rXg9s

Downloader program

ver01.cc
Downloading a single file
ver02.cc
Downloading a few files
ver03a.cc
Downloading the few files simultaneously, screen’s a mess
ver03b.cc
Added std::mutex to prevent screen from becoming a mess
ver04a.cc
Sum the sizes of the downloaded files, get wonky results
ver04b.cc
Sum the sizes correctly using std::atomic
ver04c.cc
Placing the sizes in a vector, get a complimentary crash
ver04d.cc
Fix the crash with std::mutex
ver05.cc
Greatly simplified version of above by using std::future and std::async
(in retrospect, I should have made a separate chapter about std::async, it is so important)

To compile the downloader programs, you need to first install cURLpp. Get it from www.curlpp.org, or maybe do: apt-get install libcurlpp-dev

Note that the screen updates depend on a terminal that processes VT100/ANSI escape sequences properly. Furthermore the color escapes depend on 256-color terminal support. Failing to have these will not prevent the program from compiling, but it may look a little wrong.

Future tutorial

ver10.cc
Using std::future without any “sender”
ver11.cc
Using std::future with std::promise
(in retrospect, I spent too much time talking about std::promise, nobody uses that)
ver12.cc
Testbed illustrating how the different sources for std::future work: std::async, std::packaged_task and std::promise
(And then there is std::shared_future, which I compared to a bulletin board. In std::future the get() takes the value with move-semantics (and calling it twice will not work), but in std::shared_future the get() makes a copy, so calling get() multiple times will work.)

Mutual exclusion tutorial

ver20.cc
Increment variable 2000 times, get wonky results
ver21.cc
Increment std::atomic variable 2000 times, get 2000 as expected
ver22.cc
Doubles/floats can also be made atomic, it's just a bit more work
ver23.cc
Placing stuff in vector 2000 times… Crash bang boom
ver30.cc
Placing stuff in vector 2000 times… Works properly now that we added std::mutex
ver31.cc
Demonstrating how easily a mutex turns into a deadlock, if you program like in C
ver32.cc
With std::lock_guard, the code becomes foolproof
(std::unique_lock is also an option)

Condition variable tutorial

ver40.cc
A simple producer-feeder program with a complimentary crash
ver41.cc
Producer-feeder no longer crashes, but consumes 100 % of CPU time
ver42.cc
Producer-feeder works properly now

Other resources

inputter.html
Inputter provides the automated background input that I nowadays use in my videos. It only runs in 16-bit DOS. It can also stream into Linux, if Linux is run under DOS.
editor.zip
The editor I used for video production, runs in 16-bit DOS only.
I don’t know why anyone would like a copy, considering it only runs in DOS and is buggy, but for some reason people always ask after it, so I’m providing it. Package includes the exact version of the editor that was used in the video, a syntax highlighting file for C language, and an instructions text file. The source code is also available in editor-sources.zip, but beware, there be dragons. Provided solely as-is; I will not provide any support for it.
linux.zip
The terminal program that runs Linux under DOSBox. Useless without a patch to DOSBox. The source code is also available in dosterm-sources.zip.
patch-dosbox-forkpty.txt
Apply this patch to DOSBox 0.74 source code if you want to use linux.exe. Only works if you are running DOSBox under Linux.

All material © 2016 Joel Yliluoma — http://iki.fi/bisqwit/

Appendix: Music

I used these songs in my video. I did not compose them. All of these songs are recorded with an OPL3 emulator/synthesizer, ADLMIDI, from MIDI files I made from original game music (SPC files).
artifacts.ogg
Wizardry V :: Artifacts (Kentarō Haneda) (As MIDI: wiz5-artifacts.mid)
calmtime.ogg
Star Ocean :: Calm Time (Motoi Sakuraba) (As MIDI: so-town2.mid)
house.ogg
Wonder Project J :: House (Akihito Mori) (As MIDI: wpj-07.mid)

Archive footage only:

unkai.ogg
Axelay :: Unkai (Tarō Kudō) (As MIDI: axe-unkai.mid)
geothermal.ogg
Cave Story :: Geothermal (Daisuke Amaya) (Played through a program I constructed in a different video.)