| 1 | // |
| 2 | // NamedEvent.h |
| 3 | // |
| 4 | // Library: Foundation |
| 5 | // Package: Processes |
| 6 | // Module: NamedEvent |
| 7 | // |
| 8 | // Definition of the NamedEvent class. |
| 9 | // |
| 10 | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. |
| 11 | // and Contributors. |
| 12 | // |
| 13 | // SPDX-License-Identifier: BSL-1.0 |
| 14 | // |
| 15 | |
| 16 | |
| 17 | #ifndef Foundation_NamedEvent_INCLUDED |
| 18 | #define Foundation_NamedEvent_INCLUDED |
| 19 | |
| 20 | |
| 21 | #include "Poco/Foundation.h" |
| 22 | |
| 23 | |
| 24 | #if defined(POCO_OS_FAMILY_WINDOWS) |
| 25 | #include "Poco/NamedEvent_WIN32.h" |
| 26 | #elif defined(POCO_ANDROID) |
| 27 | #include "Poco/NamedEvent_Android.h" |
| 28 | #elif defined(POCO_OS_FAMILY_UNIX) |
| 29 | #include "Poco/NamedEvent_UNIX.h" |
| 30 | #else |
| 31 | #include "Poco/NamedEvent_VMS.h" |
| 32 | #endif |
| 33 | |
| 34 | |
| 35 | namespace Poco { |
| 36 | |
| 37 | |
| 38 | class Foundation_API NamedEvent: public NamedEventImpl |
| 39 | /// An NamedEvent is a global synchronization object |
| 40 | /// that allows one process or thread to signal an |
| 41 | /// other process or thread that a certain event |
| 42 | /// has happened. |
| 43 | /// |
| 44 | /// Unlike an Event, which itself is the unit of synchronization, |
| 45 | /// a NamedEvent refers to a named operating system resource being the |
| 46 | /// unit of synchronization. |
| 47 | /// In other words, there can be multiple instances of NamedEvent referring |
| 48 | /// to the same actual synchronization object. |
| 49 | /// |
| 50 | /// NamedEvents are always autoresetting. |
| 51 | /// |
| 52 | /// There should not be more than one instance of NamedEvent for |
| 53 | /// a given name in a process. Otherwise, the instances may |
| 54 | /// interfere with each other. |
| 55 | { |
| 56 | public: |
| 57 | NamedEvent(const std::string& name); |
| 58 | /// Creates the event. |
| 59 | |
| 60 | ~NamedEvent(); |
| 61 | /// Destroys the event. |
| 62 | |
| 63 | void set(); |
| 64 | /// Signals the event. |
| 65 | /// The one thread or process waiting for the event |
| 66 | /// can resume execution. |
| 67 | |
| 68 | void wait(); |
| 69 | /// Waits for the event to become signalled. |
| 70 | |
| 71 | private: |
| 72 | NamedEvent(); |
| 73 | NamedEvent(const NamedEvent&); |
| 74 | NamedEvent& operator = (const NamedEvent&); |
| 75 | }; |
| 76 | |
| 77 | |
| 78 | // |
| 79 | // inlines |
| 80 | // |
| 81 | inline void NamedEvent::set() |
| 82 | { |
| 83 | setImpl(); |
| 84 | } |
| 85 | |
| 86 | |
| 87 | inline void NamedEvent::wait() |
| 88 | { |
| 89 | waitImpl(); |
| 90 | } |
| 91 | |
| 92 | |
| 93 | } // namespace Poco |
| 94 | |
| 95 | |
| 96 | #endif // Foundation_NamedEvent_INCLUDED |
| 97 | |