Home | History | Annotate | Download | only in platform

Lines Matching refs:Event

108 struct ConditionVariable::Event {
109 Event() : handle_(::CreateEventA(NULL, true, false, NULL)) {
113 ~Event() {
129 Event* next_;
139 Event* event = freelist_;
140 freelist_ = event->next_;
141 delete event;
146 ConditionVariable::Event* ConditionVariable::NativeHandle::Pre() {
149 // Grab an event from the free list or create a new one.
150 Event* event = freelist_;
151 if (event != NULL) {
152 freelist_ = event->next_;
154 event = new Event;
156 event->thread_ = GetCurrentThread();
157 event->notified_ = false;
160 // The event must not be on the wait list.
161 for (Event* we = waitlist_; we != NULL; we = we->next_) {
162 DCHECK_NE(event, we);
166 // Prepend the event to the wait list.
167 event->next_ = waitlist_;
168 waitlist_ = event;
170 return event;
174 void ConditionVariable::NativeHandle::Post(Event* event, bool result) {
177 // Remove the event from the wait list.
178 for (Event** wep = &waitlist_;; wep = &(*wep)->next_) {
180 if (*wep == event) {
181 *wep = event->next_;
187 // The event must not be on the free list.
188 for (Event* fe = freelist_; fe != NULL; fe = fe->next_) {
189 DCHECK_NE(event, fe);
193 // Reset the event.
194 BOOL ok = ::ResetEvent(event->handle_);
198 // Insert the event into the free list.
199 event->next_ = freelist_;
200 freelist_ = event;
202 // Forward signals delivered after the timeout to the next waiting event.
203 if (!result && event->notified_ && waitlist_ != NULL) {
222 Event* highest_event = NULL;
224 for (Event* event = native_handle().waitlist();
225 event != NULL;
226 event = event->next_) {
227 if (event->notified_) {
230 int priority = GetThreadPriority(event->thread_);
234 highest_event = event;
248 for (Event* event = native_handle().waitlist();
249 event != NULL;
250 event = event->next_) {
251 if (!event->notified_) {
252 ::SetEvent(event->handle_);
253 event->notified_ = true;
260 // Create and setup the wait event.
261 Event* event = native_handle_.Pre();
266 // Wait on the wait event.
267 while (!event->WaitFor(INFINITE)) {
273 // Release the wait event (we must have been notified).
274 DCHECK(event->notified_);
275 native_handle_.Post(event, true);
280 // Create and setup the wait event.
281 Event* event = native_handle_.Pre();
286 // Wait on the wait event.
293 result = event->WaitFor(INFINITE - 1);
299 result = event->WaitFor((msec < 0) ? 0 : static_cast<DWORD>(msec));
307 // Release the wait event.
308 DCHECK(!result || event->notified_);
309 native_handle_.Post(event, result);