summaryrefslogtreecommitdiffstats
path: root/JavaScriptCore/wtf/MessageQueue.h
diff options
context:
space:
mode:
Diffstat (limited to 'JavaScriptCore/wtf/MessageQueue.h')
-rw-r--r--JavaScriptCore/wtf/MessageQueue.h17
1 files changed, 16 insertions, 1 deletions
diff --git a/JavaScriptCore/wtf/MessageQueue.h b/JavaScriptCore/wtf/MessageQueue.h
index 12291cc..9c9a4a78 100644
--- a/JavaScriptCore/wtf/MessageQueue.h
+++ b/JavaScriptCore/wtf/MessageQueue.h
@@ -55,9 +55,13 @@ namespace WTF {
bool waitForMessage(DataType&);
template<typename Predicate>
MessageQueueWaitResult waitForMessageFilteredWithTimeout(DataType&, Predicate&, double absoluteTime);
- void kill();
+
+ template<typename Predicate>
+ void removeIf(Predicate&);
bool tryGetMessage(DataType&);
+
+ void kill();
bool killed() const;
// The result of isEmpty() is only valid if no other thread is manipulating the queue at the same time.
@@ -149,6 +153,17 @@ namespace WTF {
}
template<typename DataType>
+ template<typename Predicate>
+ inline void MessageQueue<DataType>::removeIf(Predicate& predicate)
+ {
+ MutexLocker lock(m_mutex);
+ DequeConstIterator<DataType> found = m_queue.end();
+ while ((found = m_queue.findIf(predicate)) != m_queue.end()) {
+ m_queue.remove(found);
+ }
+ }
+
+ template<typename DataType>
inline bool MessageQueue<DataType>::isEmpty()
{
MutexLocker lock(m_mutex);