Changeset 41081 in webkit for trunk/JavaScriptCore
- Timestamp:
- Feb 19, 2009, 11:40:07 AM (17 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r41068 r41081 1 2009-02-19 David Levin <[email protected]> 2 3 Reviewed by Alexey Proskuryakov. 4 5 Bug 23976: MessageQueue needs a way to wait for a message that satisfies an arbitrary criteria. 6 <https://bugs.webkit.org/show_bug.cgi?id=23976> 7 8 * wtf/Deque.h: 9 (WTF::Deque<T>::findIf): 10 * wtf/MessageQueue.h: 11 (WTF::MessageQueue<T>::waitForMessageFiltered): 12 1 13 2009-02-18 David Levin <[email protected]> 2 14 -
trunk/JavaScriptCore/wtf/Deque.h
r41068 r41081 82 82 void clear(); 83 83 84 template<typename Predicate> 85 iterator findIf(Predicate&); 86 84 87 private: 85 88 friend class DequeIteratorBase<T>; … … 354 357 } 355 358 356 template 359 template<typename T> 357 360 inline void Deque<T>::swap(Deque<T>& other) 358 361 { … … 367 370 } 368 371 369 template 372 template<typename T> 370 373 inline void Deque<T>::clear() 371 374 { … … 376 379 m_end = 0; 377 380 checkValidity(); 381 } 382 383 template<typename T> 384 template<typename Predicate> 385 inline DequeIterator<T> Deque<T>::findIf(Predicate& predicate) 386 { 387 iterator end_iterator = end(); 388 for (iterator it = begin(); it != end_iterator; ++it) { 389 if (predicate(*it)) 390 return it; 391 } 392 return end_iterator; 378 393 } 379 394 -
trunk/JavaScriptCore/wtf/MessageQueue.h
r39908 r41081 1 1 /* 2 2 * Copyright (C) 2008 Apple Inc. All rights reserved. 3 * Copyright (C) 2009 Google Inc. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 51 52 void prepend(const DataType&); 52 53 bool waitForMessage(DataType&); 54 template<typename Predicate> 55 MessageQueueWaitResult waitForMessageFiltered(DataType&, Predicate&); 53 56 MessageQueueWaitResult waitForMessageTimed(DataType&, double absoluteTime); 54 57 void kill(); … … 98 101 m_queue.removeFirst(); 99 102 return true; 103 } 104 105 template<typename DataType> 106 template<typename Predicate> 107 inline MessageQueueWaitResult MessageQueue<DataType>::waitForMessageFiltered(DataType& result, Predicate& predicate) 108 { 109 MutexLocker lock(m_mutex); 110 111 DequeConstIterator<DataType> found = m_queue.end(); 112 while (!m_killed && (found = m_queue.findIf(predicate)) == m_queue.end()) 113 m_condition.wait(m_mutex); 114 115 if (m_killed) 116 return MessageQueueTerminated; 117 118 ASSERT(found != m_queue.end()); 119 result = *found; 120 m_queue.remove(found); 121 return MessageQueueMessageReceived; 100 122 } 101 123 … … 158 180 return m_killed; 159 181 } 160 } 182 } // namespace WTF 161 183 162 184 using WTF::MessageQueue;
Note:
See TracChangeset
for help on using the changeset viewer.