Triggering an event

After playing with thread in Windows, let's try another concurrency type--Event. It is an action that can be triggered by the system. To know further about it, let's take a look at the following code snippet where we create a new class named Event that implements UniqueHandle as well:

    class Event    {      private:        NullHandle hnd;      public:        Event(Event const &) = delete;        auto operator=(Event const &)->Event & = delete;        ~Event() = default;        explicit Event(bool manual) :         hnd         {           CreateEvent(nullptr,            manual, false, nullptr)         }         {           if (!hnd)            throw WinException();         }        explicit Event(EventType evType) :         hnd         {           CreateEvent(            nullptr,            static_cast<BOOL>(evType),            false,            nullptr)         }         {           if (!hnd)            throw WinException();         } Event(Event && other) throw() : ...

Get Learning C++ Functional Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.