Skip to Main Content
C++ Concurrency in Action, Second Edition
book

C++ Concurrency in Action, Second Edition

by Anthony Williams
February 2019
Intermediate to advanced content levelIntermediate to advanced
592 pages
20h 37m
English
Manning Publications
Content preview from C++ Concurrency in Action, Second Edition

Appendix C. A message-passing framework and complete ATM example

Back in chapter 4, I presented an example of sending messages between threads using a message-passing framework, using a simple implementation of the code in an ATM as an example. What follows is the complete code for this example, including the message-passing framework.

Listing C.1 shows the message queue. It stores a list of messages as pointers to a base class; the specific message type is handled with a template class derived from that base class. Pushing an entry constructs an appropriate instance of the wrapper class and stores a pointer to it; popping an entry returns that pointer. Because the message_base class doesn’t have any member functions, the popping thread will ...

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

C++ Concurrency in Action

C++ Concurrency in Action

Anthony Williams
Programming Rust, 2nd Edition

Programming Rust, 2nd Edition

Jim Blandy, Jason Orendorff, Leonora F. S. Tindall

Publisher Resources

ISBN: 9781617294693Supplemental ContentPublisher SupportOtherPublisher WebsiteSupplemental ContentPurchase Link