Skip to Content
Modern C++ Programming with Test-Driven Development
book

Modern C++ Programming with Test-Driven Development

by Jeff Langr
October 2013
Intermediate to advanced
368 pages
9h 20m
English
Pragmatic Bookshelf
Content preview from Modern C++ Programming with Test-Driven Development

9.10 Creating Multiple Threads in the ThreadPool

Is that it? Can we ever know whether we’ve addressed all concurrency holes? To find the remaining problems, one analysis tactic is to think about any “gaps” we have—where we make an assumption about a fact that might no longer be true because of the actions of other obstreperous threads.

The ​worker​ function seems to remain the only code with any such potential. In ​worker​ , we loop until there is work; each time through the loop establishes and immediately releases a lock within ​hasWork​ . Once there is work, the loop exits, and control falls through to the statement ​pullWork().execute()​. What if, during this short span, another thread has grabbed work?

Our ThreadPool currently manages only ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Effective Modern C++

Effective Modern C++

Scott Meyers
Modern CMake for C++

Modern CMake for C++

Rafał Świdziński
Embracing Modern C++ Safely

Embracing Modern C++ Safely

John Lakos, Vittorio Romeo, Rostislav Khlebnikov, Alisdair Meredith

Publisher Resources

ISBN: 9781941222423Errata