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 POCO_OS == POCO_OS_ANDROID
27#include "Poco/NamedEvent_Android.h"
28#elif defined(POCO_OS_FAMILY_UNIX)
29#include "Poco/NamedEvent_UNIX.h"
30#endif
31
32
33namespace Poco {
34
35
36class Foundation_API NamedEvent: public NamedEventImpl
37 /// An NamedEvent is a global synchronization object
38 /// that allows one process or thread to signal an
39 /// other process or thread that a certain event
40 /// has happened.
41 ///
42 /// Unlike an Event, which itself is the unit of synchronization,
43 /// a NamedEvent refers to a named operating system resource being the
44 /// unit of synchronization.
45 /// In other words, there can be multiple instances of NamedEvent referring
46 /// to the same actual synchronization object.
47 ///
48 /// NamedEvents are always autoresetting.
49 ///
50 /// There should not be more than one instance of NamedEvent for
51 /// a given name in a process. Otherwise, the instances may
52 /// interfere with each other.
53{
54public:
55 NamedEvent(const std::string& name);
56 /// Creates the event.
57
58 ~NamedEvent();
59 /// Destroys the event.
60
61 void set();
62 /// Signals the event.
63 /// The one thread or process waiting for the event
64 /// can resume execution.
65
66 void wait();
67 /// Waits for the event to become signalled.
68
69private:
70 NamedEvent();
71 NamedEvent(const NamedEvent&);
72 NamedEvent& operator = (const NamedEvent&);
73};
74
75
76//
77// inlines
78//
79inline void NamedEvent::set()
80{
81 setImpl();
82}
83
84
85inline void NamedEvent::wait()
86{
87 waitImpl();
88}
89
90
91} // namespace Poco
92
93
94#endif // Foundation_NamedEvent_INCLUDED
95