Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying C++ Reactive Programming
  • Table Of Contents Toc
  • Feedback & Rating feedback
C++ Reactive Programming

C++ Reactive Programming

By : Praseed Pai, Abraham
3 (8)
close
close
C++ Reactive Programming

C++ Reactive Programming

3 (8)
By: Praseed Pai, Abraham

Overview of this book

Reactive programming is an effective way to build highly responsive applications with an easy-to-maintain code base. This book covers the essential functional reactive concepts that will help you build highly concurrent, event-driven, and asynchronous applications in a simpler and less error-prone way. C++ Reactive Programming begins with a discussion on how event processing was undertaken by different programming systems earlier. After a brisk introduction to modern C++ (C++17), you’ll be taken through language-level concurrency and the lock-free programming model to set the stage for our foray into the Functional Programming model. Following this, you’ll be introduced to RxCpp and its programming model. You’ll be able to gain deep insights into the RxCpp library, which facilitates reactive programming. You’ll learn how to deal with reactive programming using Qt/C++ (for the desktop) and C++ microservices for the Web. By the end of the book, you will be well versed with advanced reactive programming concepts in modern C++ (C++17).
Table of Contents (20 chapters)
close
close
Title Page
Copyright and Credits
Packt Upsell
Contributors
Preface
chevron up
Index

Preface

This book will help you learn how to implement the reactive programming paradigm with C++ and build asynchronous and concurrent applications. The book includes real-world problems that you will solve with the reactive programming model. It highlights the way event processing has evolved in the programming world. You will learn about language-level concurrency in C++ and functional reactive programming. Constructs in functional programming and object-oriented programming will enable you to write efficient programs. After this, you will learn about microservices in C++ and create your custom operators for RxCpp.

Who this book is for

If you're a C++ developer interested in using reactive programming to build asynchronous and concurrent applications, you'll find this book extremely useful. This book doesn't assume any previous knowledge of reactive programming.

What this book covers

Chapter 1, Reactive Programming Model – Overview and History, introduces some key data structures of the Rx programming model. It also covers GUI event handling, an overview of reactive programming, and an implementation of GUI versions of different interfaces on top of MFC.

Chapter 2, A Tour of Modern C++ and its Key Idioms, covers C++ features, type inference, variadic templates, rvalue references and move semantics, lambda functions, elementary functional programming, pipeable operators, and implementation of iterators and observers.

Chapter 3,  Language-Level Concurrency and Parallelism in C++, discusses the threading library available in the C++ standard. You will learn how to launch and manage a thread, and discuss different aspects of the threading library. This chapter lays a good foundation for concurrency support introduced in Modern C++.

Chapter 4, Asynchronous and Lock-Free Programming in C++, discusses the facilities provided by the standard library for writing task-based parallelism. It also discusses the new multithreading-aware memory model that is available with the Modern C++ language.

 Chapter 5, Introduction to Observables, talks about the GoF Observer pattern and explains its shortcomings. You will learn about the GoF Composite/Visitor pattern in the context of modeling an expression tree.

Chapter 6, Introduction to Event Stream Programming Using C++, focuses on the topic of event Stream programming. We will also look at the Streamulus library, which provides a DSEL approach to the manipulation of event Streams, followed by a couple of programs.

Chapter 7, Introduction to Data Flow Computation and the RxCpp Library, starts with a conceptual overview of the data flow computing paradigm and moves quickly to writing some basic RxCpp programs. You will learn about the set of operators supported by the RxCpp library.

Chapter 8,  RxCpp – the Key Elements, gives you an understanding of how pieces of the Rx programming model fit together. The chapter starts with Observables and moves on to cover the subscription mechanism and scheduler implementation.

Chapter 9, Reactive GUI Programming Using Qt/C++, deals with the topic of reactive GUI programming using Qt. You will learn about concepts in the Qt framework, such as the Qt object hierarchy, the meta-object system, and signals and slots. Then, you will write an application to handle mouse events and filter them. After this you will also learn advanced topic of how we can create custom reactive operators in RxCpp, should an existing set of operators not suffice for the purpose. This topic also helps you create composite operators by composing the existing operators. This topic is not present in the book, but it is available for download at https://www.packtpub.com/sites/default/files/downloads/Creating_Custom_Operators_in_RxCpp.pdf.

Chapter 10, Design Patterns and Idioms for C++ Rx Programming, delves into the wonderful world of design patterns and idioms. Starting with GOF design patterns, we will move on to reactive programming patterns.

Chapter 11Reactive Microservices Using C++, covers how the Rx programming model can be used to write reactive microservices using C++. It introduces you to the Microsoft C++ REST SDK and its programming model.

Chapter 12, Advanced Streams and Handling Errors, discusses error handling in RxCpp, along with some of the advanced constructs and operators that handle Streams in the RxCpp library. We will discuss how to continue Streams when an error comes, how to wait for the producer of the Stream to correct the error and continue the sequence, and how to perform common operations that are applicable to both success and error paths.

To get the most out of this book

In order to follow the topics in this book, you need to have a knowledge of C++ programming.

Download the example code files

You can download the example code files for this book from your account at www.packtpub.com. If you purchased this book elsewhere, you can visit www.packtpub.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at www.packtpub.com.
  2. Select the SUPPORT tab.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR/7-Zip for Windows
  • Zipeg/iZip/UnRarX for Mac
  • 7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/CPP-Reactive-Programming. In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Download the color images

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://www.packtpub.com/sites/default/files/downloads/CPPReactiveProgramming_ColorImages.pdf.

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "The preceding code snippet initializes a structure by the name of WNDCLASS (or WNDCLASSEX for modern systems) with a necessary template for a window."

A block of code is set as follows:

/* close connection to server */
XCloseDisplay(display);

return 0;
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

/* close connection to server */
XCloseDisplay(display);

return 0;
}

Any command-line input or output is written as follows:

$ mkdir css
$ cd css

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "In Windowing parlance, it is called a message loop."

Note

Warnings or important notes appear like this.

Note

Tips and tricks appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: Email [email protected] and mention the book title in the subject of your message. If you have questions about any aspect of this book, please email us at [email protected].

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Reviews

Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit packtpub.com.

Limited Time Offer

$10p/m for 3 months

Get online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech and supported with AI assistants
notes
bookmark search playlist download font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon

Create a Note

Modal Close icon
You need to login to use this feature.

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Delete Note

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Edit Note

Modal Close icon
Write a note (max 255 characters)
Cancel
Update Note