Ignore:
Timestamp:
Oct 28, 2009, 4:21:31 PM (16 years ago)
Author:
[email protected]
Message:

JavaScriptCore: Add MessageQueue::removeIf(Predicate&) to remove certain tasks without pulling them from the queue.
Existing Database tests cover this since Database removes tasks when it is stopped.
https://bugs.webkit.org/show_bug.cgi?id=30805

Reviewed by David Levin.

  • wtf/MessageQueue.h:

(WTF::::removeIf):

WebCore: Add MessageQueue::removeIf(Predicate&) to remove certain tasks without pulling them from the queue.
Existing Database tests cover this, no change in functionality.
https://bugs.webkit.org/show_bug.cgi?id=30805

Reviewed by David Levin.

  • storage/DatabaseThread.cpp:

(WebCore::SameDatabasePredicate::SameDatabasePredicate): Added predicate that flags the tasks belonging to a specified database.
(WebCore::SameDatabasePredicate::operator()):
(WebCore::DatabaseThread::unscheduleDatabaseTasks): changed to use the new removeIf method.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/MessageQueue.h

    r45891 r50247  
    5656        template<typename Predicate>
    5757        MessageQueueWaitResult waitForMessageFilteredWithTimeout(DataType&, Predicate&, double absoluteTime);
    58         void kill();
     58
     59        template<typename Predicate>
     60        void removeIf(Predicate&);
    5961
    6062        bool tryGetMessage(DataType&);
     63
     64        void kill();
    6165        bool killed() const;
    6266
     
    150154
    151155    template<typename DataType>
     156    template<typename Predicate>
     157    inline void MessageQueue<DataType>::removeIf(Predicate& predicate)
     158    {
     159        MutexLocker lock(m_mutex);
     160        DequeConstIterator<DataType> found = m_queue.end();
     161        while ((found = m_queue.findIf(predicate)) != m_queue.end()) {
     162            m_queue.remove(found);
     163       }
     164    }
     165
     166    template<typename DataType>
    152167    inline bool MessageQueue<DataType>::isEmpty()
    153168    {
Note: See TracChangeset for help on using the changeset viewer.