From the course: Functional Programming in C++

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

Benefits of functional programming for asynchronous event handling

Benefits of functional programming for asynchronous event handling - C++ Tutorial

From the course: Functional Programming in C++

Benefits of functional programming for asynchronous event handling

- [Instructor] All right, welcome to this example. In this example, we're going to go over the benefits of functional programming for asynchronous event handling. I know that's a mouthful, but essentially what we're going to do is we're going to show how we can have different asynchronous tasks executing at the same time. Now, our program is just an example, but once you get the benefits and the technique in your head, it will help you immensely with your C++ programming. So we're going to begin by using an event handler. And so we're creating this, EventHandler, and it is going to equal std::function. So we are creating a function almost out of thin air, and it's going to be a void, which means it has no return value, const std::string, and it's going to be a reference to a string. And let's close off that angle bracket, and a semicolon. Next we're going to have a simulated event source. So this is going to be another void simulateEventSource, and it's going to take in as a…

Contents