X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/f9bf01c6616d5ddcf65b13b33cedf9e387ff7a63..14957cd040308e3eeec43d26bae5d76da13fcd85:/wtf/MessageQueue.h diff --git a/wtf/MessageQueue.h b/wtf/MessageQueue.h index 48bd10a..3e48154 100644 --- a/wtf/MessageQueue.h +++ b/wtf/MessageQueue.h @@ -41,14 +41,15 @@ namespace WTF { enum MessageQueueWaitResult { MessageQueueTerminated, // Queue was destroyed while waiting for message. MessageQueueTimeout, // Timeout was specified and it expired. - MessageQueueMessageReceived, // A message was successfully received and returned. + MessageQueueMessageReceived // A message was successfully received and returned. }; // The queue takes ownership of messages and transfer it to the new owner // when messages are fetched from the queue. // Essentially, MessageQueue acts as a queue of OwnPtr. template - class MessageQueue : public Noncopyable { + class MessageQueue { + WTF_MAKE_NONCOPYABLE(MessageQueue); public: MessageQueue() : m_killed(false) { } ~MessageQueue(); @@ -92,7 +93,7 @@ namespace WTF { inline void MessageQueue::append(PassOwnPtr message) { MutexLocker lock(m_mutex); - m_queue.append(message.release()); + m_queue.append(message.leakPtr()); m_condition.signal(); } @@ -102,7 +103,7 @@ namespace WTF { { MutexLocker lock(m_mutex); bool wasEmpty = m_queue.isEmpty(); - m_queue.append(message.release()); + m_queue.append(message.leakPtr()); m_condition.signal(); return wasEmpty; } @@ -111,7 +112,7 @@ namespace WTF { inline void MessageQueue::prepend(PassOwnPtr message) { MutexLocker lock(m_mutex); - m_queue.prepend(message.release()); + m_queue.prepend(message.leakPtr()); m_condition.signal(); } @@ -119,9 +120,9 @@ namespace WTF { inline PassOwnPtr MessageQueue::waitForMessage() { MessageQueueWaitResult exitReason; - PassOwnPtr result = waitForMessageFilteredWithTimeout(exitReason, MessageQueue::alwaysTruePredicate, infiniteTime()); + OwnPtr result = waitForMessageFilteredWithTimeout(exitReason, MessageQueue::alwaysTruePredicate, infiniteTime()); ASSERT(exitReason == MessageQueueTerminated || exitReason == MessageQueueMessageReceived); - return result; + return result.release(); } template @@ -139,19 +140,19 @@ namespace WTF { if (m_killed) { result = MessageQueueTerminated; - return 0; + return nullptr; } if (timedOut) { result = MessageQueueTimeout; - return 0; + return nullptr; } ASSERT(found != m_queue.end()); - DataType* message = *found; + OwnPtr message = adoptPtr(*found); m_queue.remove(found); result = MessageQueueMessageReceived; - return message; + return message.release(); } template @@ -159,13 +160,11 @@ namespace WTF { { MutexLocker lock(m_mutex); if (m_killed) - return 0; + return nullptr; if (m_queue.isEmpty()) - return 0; + return nullptr; - DataType* message = m_queue.first(); - m_queue.removeFirst(); - return message; + return adoptPtr(m_queue.takeFirst()); } template