Home | History | Annotate | Download | only in platform

Lines Matching refs:Event

121 struct ConditionVariable::Event {
122 Event() : handle_(::CreateEventA(NULL, true, false, NULL)) {
126 ~Event() {
142 Event* next_;
152 Event* event = freelist_;
153 freelist_ = event->next_;
154 delete event;
159 ConditionVariable::Event* ConditionVariable::NativeHandle::Pre() {
162 // Grab an event from the free list or create a new one.
163 Event* event = freelist_;
164 if (event != NULL) {
165 freelist_ = event->next_;
167 event = new Event;
169 event->thread_ = GetCurrentThread();
170 event->notified_ = false;
173 // The event must not be on the wait list.
174 for (Event* we = waitlist_; we != NULL; we = we->next_) {
175 DCHECK_NE(event, we);
179 // Prepend the event to the wait list.
180 event->next_ = waitlist_;
181 waitlist_ = event;
183 return event;
187 void ConditionVariable::NativeHandle::Post(Event* event, bool result) {
190 // Remove the event from the wait list.
191 for (Event** wep = &waitlist_;; wep = &(*wep)->next_) {
193 if (*wep == event) {
194 *wep = event->next_;
200 // The event must not be on the free list.
201 for (Event* fe = freelist_; fe != NULL; fe = fe->next_) {
202 DCHECK_NE(event, fe);
206 // Reset the event.
207 BOOL ok = ::ResetEvent(event->handle_);
211 // Insert the event into the free list.
212 event->next_ = freelist_;
213 freelist_ = event;
215 // Forward signals delivered after the timeout to the next waiting event.
216 if (!result && event->notified_ && waitlist_ != NULL) {
235 Event* highest_event = NULL;
237 for (Event* event = native_handle().waitlist();
238 event != NULL;
239 event = event->next_) {
240 if (event->notified_) {
243 int priority = GetThreadPriority(event->thread_);
247 highest_event = event;
261 for (Event* event = native_handle().waitlist();
262 event != NULL;
263 event = event->next_) {
264 if (!event->notified_) {
265 ::SetEvent(event->handle_);
266 event->notified_ = true;
273 // Create and setup the wait event.
274 Event* event = native_handle_.Pre();
279 // Wait on the wait event.
280 while (!event->WaitFor(INFINITE)) {
286 // Release the wait event (we must have been notified).
287 DCHECK(event->notified_);
288 native_handle_.Post(event, true);
293 // Create and setup the wait event.
294 Event* event = native_handle_.Pre();
299 // Wait on the wait event.
306 result = event->WaitFor(INFINITE - 1);
312 result = event->WaitFor((msec < 0) ? 0 : static_cast<DWORD>(msec));
320 // Release the wait event.
321 DCHECK(!result || event->notified_);
322 native_handle_.Post(event, result);