source: XMLIO_V2/external/src/POCO/Foundation.save/Poco/Event.h @ 80

Last change on this file since 80 was 80, checked in by ymipsl, 14 years ago

ajout lib externe

  • Property svn:eol-style set to native
File size: 3.5 KB
Line 
1//
2// Event.h
3//
4// $Id: //poco/1.3/Foundation/include/Poco/Event.h#2 $
5//
6// Library: Foundation
7// Package: Threading
8// Module:  Event
9//
10// Definition of the Event class.
11//
12// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
13// and Contributors.
14//
15// Permission is hereby granted, free of charge, to any person or organization
16// obtaining a copy of the software and accompanying documentation covered by
17// this license (the "Software") to use, reproduce, display, distribute,
18// execute, and transmit the Software, and to prepare derivative works of the
19// Software, and to permit third-parties to whom the Software is furnished to
20// do so, all subject to the following:
21//
22// The copyright notices in the Software and this entire statement, including
23// the above license grant, this restriction and the following disclaimer,
24// must be included in all copies of the Software, in whole or in part, and
25// all derivative works of the Software, unless such copies or derivative
26// works are solely in the form of machine-executable object code generated by
27// a source language processor.
28//
29// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
32// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
33// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
34// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
35// DEALINGS IN THE SOFTWARE.
36//
37
38
39#ifndef Foundation_Event_INCLUDED
40#define Foundation_Event_INCLUDED
41
42
43#include "Poco/Foundation.h"
44#include "Poco/Exception.h"
45
46
47#if defined(POCO_OS_FAMILY_WINDOWS)
48#include "Poco/Event_WIN32.h"
49#else
50#include "Poco/Event_POSIX.h"
51#endif
52
53
54namespace Poco {
55
56
57class Foundation_API Event: private EventImpl
58        /// An Event is a synchronization object that
59        /// allows one thread to signal one or more
60        /// other threads that a certain event
61        /// has happened.
62        /// Usually, one thread signals an event,
63        /// while one or more other threads wait
64        /// for an event to become signalled.
65{
66public:
67        Event(bool autoReset = true);
68                /// Creates the event. If autoReset is true,
69                /// the event is automatically reset after
70                /// a wait() successfully returns.
71               
72        ~Event();
73                /// Destroys the event.
74
75        void set();
76                /// Signals the event. If autoReset is true,
77                /// only one thread waiting for the event
78                /// can resume execution.
79                /// If autoReset is false, all waiting threads
80                /// can resume execution.
81
82        void wait();
83                /// Waits for the event to become signalled.
84
85        void wait(long milliseconds);
86                /// Waits for the event to become signalled.
87                /// Throws a TimeoutException if the event
88                /// does not become signalled within the specified
89                /// time interval.
90
91        bool tryWait(long milliseconds);
92                /// Waits for the event to become signalled.
93                /// Returns true if the event
94                /// became signalled within the specified
95                /// time interval, false otherwise.
96
97        void reset();
98                /// Resets the event to unsignalled state.
99       
100private:
101        Event(const Event&);
102        Event& operator = (const Event&);
103};
104
105
106//
107// inlines
108//
109inline void Event::set()
110{
111        setImpl();
112}
113
114
115inline void Event::wait()
116{
117        waitImpl();
118}
119
120
121inline void Event::wait(long milliseconds)
122{
123        if (!waitImpl(milliseconds))
124                throw TimeoutException();
125}
126
127
128inline bool Event::tryWait(long milliseconds)
129{
130        return waitImpl(milliseconds);
131}
132
133
134inline void Event::reset()
135{
136        resetImpl();
137}
138
139
140} // namespace Poco
141
142
143#endif // Foundation_Event_INCLUDED
Note: See TracBrowser for help on using the repository browser.