Re:C++11 threads, affinity and hyperthreading
by superfunc on Monday January 18, 2016 @02:11PM
(#10926204)
Also, if people should look at intel's tbb(https://www.threadingbuildingblocks.org/intel-tbb-tutorial) library, it has been really excellent in my experience using at a respectably large scale.
edit: formatting
Re:C++11 threads, affinity and hyperthreading
by bonzini on Tuesday January 19, 2016 @02:46AM
(#10929299)
TBB is a little underwhelming in my opinion. Stuff like mutexes, condition variables and even atomics is pretty much standard nowadays (even if you need portability, you can usually rely on stuff like glib or Qt or boost); thread-safe collections are rarely the right solution, because too many fine-grained locks incur excessive overhead. The work-stealing queue is nice, but if you really want things to scale you need stuff like highly-parallel fast paths, with message passing on the slow paths. And this is where TBB falls a bit short of the expectations.
Re:C++11 threads, affinity and hyperthreading
by pkolaczk on Tuesday January 19, 2016 @06:20AM
(#10929980)
I wonder what do you find so simplifying in futures and promises? I use them heavily in one of the projects and compared to old-school mutexes and condition variables they seem to be just at the same abstraction level. They can cause very similar problems like deadlocks or race conditions, with the additional "bonus" of callback hell if you don't use any higher-level libraries.
That's fine, but just as an FYI to others: C++11 also provides some great tools for creating futures and promises that significantly simplify the work in multithreaded programming. In fact it closely resembles the conveniences I came to enjoy working in Clojure, which is considered to have a great approach to threading.