Reddit Reddit reviews C++ Concurrency in Action: Practical Multithreading

We found 12 Reddit comments about C++ Concurrency in Action: Practical Multithreading. Here are the top ones, ranked by their Reddit score.

Computers & Technology
Books
Computer Programming
C++ Concurrency in Action: Practical Multithreading
Check price on Amazon

12 Reddit comments about C++ Concurrency in Action: Practical Multithreading:

u/flipcoder · 36 pointsr/gamedev

Guard your render thread's quit flag somehow, or use atomic_flag or condition_variable. You're modifying and checking it in two diff threads. Also, read up on RAII, it'll save you. the rendy object lifetime destructor happens after SDL_Quit(). This is probably fine with SDL, but be aware that improper ordering of destruction can result in memory leaks and crashing with other libs and even in your own code. Just some tips :)

EDIT: Oh yeah, you don't need "this->" everywhere. You only need it for "this->window = window;" because of the name clash.

EDIT2: SDL_DestroyWindow needs to be called on the same thread that created it. I think this is a platform-specific limitation.

EDIT3: I was suspecting that there was another issue with the SDL state access between threads but I could not remember the rules for it. /u/nope_dot_avi's comment is correct, the unprotected window data is accessed by 2 threads.

Anyone wishing to dive into concurrency should Read this book

u/MrBushido2318 · 20 pointsr/gamedev

You have a long journey ahead of you, but here goes :D

Beginner

C++ Primer: One of the better introductory books.

The C++ Standard Template Library: A Tutorial and Reference: Goes over the standard template library in fantastic detail, a must if you're going to be spending a lot of time writing C++.

The C++ Programming Language: Now that you have a good idea of how C++ is used, it's time to go over it again. TCPPL is written by the language's creator and is intended as an introductory book for experienced programmers. That said I think it's best read once you're already comfortable with the language so that you can full appreciate his nuggets of wisdom.


Intermediate

Modern C++ Design: Covers how to write reusable C++ code and common design patterns. You can definitely have started game programming by the time you read this book, however it's definitely something you should have on your reading list.

C++ Templates: Touches on some similar material as Modern C++ Design, but will help you get to grips with C++ Template programming and how to write reusable code.

Effective C++: Practical advise about C++ do's and dont's. Again, this isn't mandatory knowledge for gamedev, but it's advice is definitely invaluable.

Design Patterns: Teaches you commonly used design patterns. Especially useful if you're working as part of a team as it gives you a common set of names for design patterns.

Advanced

C++ Concurrency in Action: Don't be put off by the fact I've put this as an "advanced" topic, it's more that you will get more benefit out of knowing the other subjects first. Concurrency in C++11 is pretty easy and this book is a fantastic guide for learning how its done.

Graphics Programming

OpenGL: A surprisingly well written specification in that it's pretty easy to understand! While it's probably not the best resource for learning OpenGL, it's definitely worth looking at. [edit: Mix it in with Open.gl and arcsynthesis's tutorials for practical examples and you're off to a good start!]

OpenGL Superbible: The OpenGL superbible is one of the best ways to learn modern OpenGL. Sadly this isn't saying much, in fact the only other book appears to be the "Orange Book", however my sources indicate that is terrible. So you're just going to have suck it up and learn from the OGL Superbible![edit: in retrospect, just stick to free tutorials I've linked above. You'll learn more from them, and be less confused by what is 3rd party code supplied by the book. Substitute the "rendering" techniques you would learn from a 3d book with a good 3d math book and realtime rendering (links below)]


Essential Mathematics for Game Programmers or 3D Math Primer for Graphics and Game Development: 3D programming involves a lot of math, these books cover topics that OpenGL/DirectX books tend to rush over.

Realtime Rendering: A graphics library independent explanation of a number of modern graphical techniques, very useful with teaching you inventive ways to use your newly found 3d graphical talents!

u/cdglove · 11 pointsr/cpp

Anthony Williams' book, C++ Concurrency in Action is an excellent book. Everything from the basics of creating a thread to managing the memory order of atomic ops is discussed. It's expensive, but a really good read.

https://www.amazon.com/C-Concurrency-Action-Practical-Multithreading/dp/1933988770

u/slei1337 · 7 pointsr/cpp

I recommend the book linked below (others probably already linked this one), I think there is an newer version out already. It covers beginner knowledge and also advanced high performance stuff like atomics and the memory models.


https://www.amazon.com/C-Concurrency-Action-Practical-Multithreading/dp/1933988770


Additionally once you have some knowledge some cppcon talks I found really interesting:
https://youtu.be/c1gO9aB9nbs
https://youtu.be/CmxkPChOcvw
https://youtu.be/X1T3IQ4N-3g

https://youtu.be/qKm-9gC4xpY
https://youtu.be/8_lhcZk5zEs

u/StackedCrooked · 5 pointsr/cpp

If you want to have a more in-depth understanding of the topic I recommend that you to learn about the C++ memory model. The best resource I found is chapter 5 of the book C++ Concurrency in Action.

It's also helpful to learn about the MESI cache coherence protocol used by modern CPUs.

u/zzyzzyxx · 3 pointsr/learnprogramming

I don't know about multithreading books in general and StackOverflow was surprisingly silent on the issue in my search, except for some specific languages. For C++11 there is C++ Concurrency in Action by Anthony Williams, who worked on the new standard, authored the just::thread library, and maintains Boost.Thread. There is this introductory video series on C++11 concurrency by Bartosz Milewski, who also did some work on the new standard in the concurrency subgroup.

u/Crazy__Eddie · 2 pointsr/cpp

You forgot a 4th method of keeping threads from stomping on each other: immutable data.

This usually still requires some sort of reference counting mechanism if you're passing around this immutable data, but if its in global scope/lifetime even that's unnecessary. At any rate, that is pretty simple to facilitate and then basically ignore.

Never writing to shared data is my personal favorite way to deal with MT issues. In fact I like to push the fact that data is even shared behind a value object so different threads of execution look like they're working with independent values. Way easier to reason about that way.

Not always possible though. Sometimes it is just not the right answer. I find though that being as close to pure-functional as you can get is quite often the easiest and fastest approach. Making copies of everything all the time seems expensive, and for any one thread it is, but it often scales better than the alternatives.

I would also add that anyone wishing to get into MT in C++ should buy Wiliams's book. He does pretty good at explaining the kinds of issues you're talking about and showing what it takes to make a thread safe container interface...it is doable but they're pretty different from the non-safe versions.

u/__cplusplus · 2 pointsr/cpp

C++ Concurrency in Action by Anthony Williams talks about threads in detail (as well as mutexes, lock guards, and the C++ memory model). Here's an amazon link. Here's a pdf version : (note that you have to click the link under e-book to get the file) here.

u/phao · 1 pointr/learnprogramming

> Do you know any ressources about how to structure the source code of a C++ application?

That falls into the pretty difficult stuff category, doesn't it? =)

Questions like

  • Given a problem:
  • How many X will I have? (which parts)
  • What should they contain? (what is inside the parts)
  • Where should they go? (where are the parts)

    ... where X can be functions, overloading, class types (struct, union, class), enum/enum class, templates (functions or classes), exceptions, virtual functions, and so forth, is a huge part of doing it correctly.

    There are many books on program structures for OOP (like Grady Booch's). For procedural programming, I don't really know any specific, which is a shame. I've heard of the term "structured design" a bunch of times, and I think it's relevant here, but I'm not so sure.

    There is also the issue of concurrent programming. I've heard this one is pretty good => http://www.amazon.com/C-Concurrency-Action-Practical-Multithreading/dp/1933988770/.

    The C++ I mentioned back then talk about this issue too.

    Edit: Functional programming in C++ is getting sort of popular. So you can take a look at some functional programming books to see what they have to say. But it seems to me that the occasions aren't many that one can apply FP in C++ and at the same time benefit from it. Who knows? There is this guy who, besides other things, is a C++ and Haskell programmer and writes a lot about functional and concurrent programming in C++. His blog is http://bartoszmilewski.com/.
u/IceShiver · 1 pointr/cpp_questions

Personally I think it is best to learn c++ by reading books.

In this case the book would be: https://www.amazon.de/C-Concurrency-Action-Anthony-Williams/dp/1933988770

It starts slow with basic multi threading later explains atomics, memory model and other more advanced things with plenty of examples.

u/Shokwav · 1 pointr/cpp

Would you recommend Effective Modern C++? I've been writing in C++ for 2-3 years now, and I've already read "Effective C++" and "More Effective C++" cover-to-cover, so I wouldn't consider myself a newbie... mainly, I'm just looking to learn multithreading, and I was considering a book such as this one.