Book Image

Boost C++ Application Development Cookbook

By : Antony Polukhin
Book Image

Boost C++ Application Development Cookbook

By: Antony Polukhin

Overview of this book

<p>Boost libraries are developed by professionals, tested on multiple platforms and processor architectures, and contain reliable solutions for a wide range of tasks. This Cookbook takes you on a journey of simplifying the process of application development and guides you through writing perfect applications fast.</p> <p>"Boost C++ Application Development Cookbook" provides you with a number of clear step-by-step recipes that will help you take advantage of the real power of Boost and C++, while giving you a good grounding in using it in any project.</p> <p>"Boost C++ Application Development Cookbook" looks at the Boost libraries, and breaks down the mystery and confusion about which library to use in which situation. It will take you through a number of clear, practical recipes that will help you to take advantage of the readily available solutions.</p> <p>Boost C++ Application Development Cookbook starts with teaching the basics of Boost libraries that are now mostly part of C++11 and leave no chance for memory leaks. Managing resources will become a piece of cake. We’ll see what kind of work can be done at compile time and what Boost containers can do. Do you think multithreading is a burden? Not with Boost. Think writing portable and fast servers is impossible? You’ll be surprised! Compilers and operating systems differ too much? Not with Boost. From manipulating images to graphs, directories, timers, files, strings – everyone will find an interesting topic.</p> <p>You will learn everything for the development of high quality fast and portable applications. Write a program once and then you can use it on Linux, Windows, MacOS, Android operating systems.</p>
Table of Contents (19 chapters)
Boost C++ Application Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Syncing interprocess communications


In the previous recipe, we saw how to create shared memory and how to place some objects in it. Now it's time to do something useful. Let's take an example from the Creating a work_queue class recipe in Chapter 5, Multithreading, and make it work for multiple processes. At the end of this example, we'll get a class that can store different tasks and pass them between processes.

Getting ready

This recipe uses techniques from the previous one. You will also need to read the Creating a work_queue class recipe in Chapter 5, Multithreading, and get its main idea. The example requires linking against the runtime library on some platforms.

How to do it...

It is considered that spawning separate subprocesses instead of threads makes a program more reliable, because termination of a subprocess won't terminate the main process. We won't argue with that assumption here, and just see how data sharing between processes can be implemented.

  1. A lot of headers are required for...