当前位置: 首页>>代码示例>>C++>>正文


C++ MessageID类代码示例

本文整理汇总了C++中MessageID的典型用法代码示例。如果您正苦于以下问题:C++ MessageID类的具体用法?C++ MessageID怎么用?C++ MessageID使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MessageID类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: dispatchSyncMessage

void Connection::dispatchSyncMessage(MessageID messageID, ArgumentDecoder* arguments)
{
    ASSERT(messageID.isSync());

    // Decode the sync request ID.
    uint64_t syncRequestID = 0;

    if (!arguments->decodeUInt64(syncRequestID) || !syncRequestID) {
        // We received an invalid sync message.
        arguments->markInvalid();
        return;
    }

    // Create our reply encoder.
    ArgumentEncoder* replyEncoder = ArgumentEncoder::create(syncRequestID).leakPtr();
    
    // Hand off both the decoder and encoder to the client..
    SyncReplyMode syncReplyMode = m_client->didReceiveSyncMessage(this, messageID, arguments, replyEncoder);

    // FIXME: If the message was invalid, we should send back a SyncMessageError.
    ASSERT(!arguments->isInvalid());

    if (syncReplyMode == ManualReply) {
        // The client will take ownership of the reply encoder and send it at some point in the future.
        // We won't do anything here.
        return;
    }

    // Send the reply.
    sendSyncReply(replyEncoder);
}
开发者ID:,项目名称:,代码行数:31,代码来源:

示例2: sendOutgoingMessage

bool Connection::sendOutgoingMessage(MessageID messageID, PassOwnPtr<ArgumentEncoder> arguments)
{
    ASSERT(m_socket);

    // We put the message ID last.
    arguments->encodeUInt32(messageID.toInt());

    size_t bufferSize = arguments->bufferSize();

    // Write message size first
    // FIXME: Should  just do a single write.
    qint64 bytesWrittenForSize = m_socket->write(reinterpret_cast<char*>(&bufferSize), sizeof(bufferSize));
    if (bytesWrittenForSize != sizeof(bufferSize)) {
        connectionDidClose();
        return false;
    }

    qint64 bytesWrittenForBuffer = m_socket->write(reinterpret_cast<char*>(arguments->buffer()), arguments->bufferSize());
    if (bytesWrittenForBuffer != arguments->bufferSize()) {
        connectionDidClose();
        return false;
    }

    m_socket->flush();

    return true;
}
开发者ID:,项目名称:,代码行数:27,代码来源:

示例3: locker

std::auto_ptr<ArgumentDecoder> Connection::waitForMessage(MessageID messageID, uint64_t destinationID, double timeout)
{
    // First, check if this message is already in the incoming messages queue.
    {
        MutexLocker locker(m_incomingMessagesLock);

        for (size_t i = 0; i < m_incomingMessages.size(); ++i) {
            const IncomingMessage& message = m_incomingMessages[i];

            if (equalIgnoringFlags(message.messageID(), messageID) && message.arguments()->destinationID() == destinationID) {
                std::auto_ptr<ArgumentDecoder> arguments(message.arguments());
                
                // Erase the incoming message.
                m_incomingMessages.remove(i);
                return arguments;
            }
        }
    }
    
    double absoluteTime = currentTime() + timeout;
    
    std::pair<unsigned, uint64_t> messageAndDestination(std::make_pair(messageID.toInt(), destinationID));
    
    {
        MutexLocker locker(m_waitForMessageMutex);

        // We don't support having multiple clients wait for the same message.
        ASSERT(!m_waitForMessageMap.contains(messageAndDestination));
    
        // Insert our pending wait.
        m_waitForMessageMap.set(messageAndDestination, 0);
    }
    
    bool timedOut = false;
    
    // Now wait for it to be set.
    while (!timedOut) {
        MutexLocker locker(m_waitForMessageMutex);

        HashMap<std::pair<unsigned, uint64_t>, ArgumentDecoder*>::iterator it = m_waitForMessageMap.find(messageAndDestination);
        if (it->second) {
            std::auto_ptr<ArgumentDecoder> arguments(it->second);
            m_waitForMessageMap.remove(it);
            
            return arguments;
        }
        
        // We didn't find it, keep waiting.
        timedOut = !m_waitForMessageCondition.timedWait(m_waitForMessageMutex, absoluteTime);
    }

    // We timed out, now remove the pending wait.
    {
        MutexLocker locker(m_waitForMessageMutex);
        m_waitForMessageMap.remove(messageAndDestination);
    }
    
    return std::auto_ptr<ArgumentDecoder>();
}
开发者ID:UIKit0,项目名称:WebkitAIR,代码行数:59,代码来源:Connection.cpp

示例4: dispatchSyncMessage

bool MessageReceiverMap::dispatchSyncMessage(Connection* connection, MessageID messageID, ArgumentDecoder* argumentDecoder, OwnPtr<ArgumentEncoder>& reply)
{
    if (MessageReceiver* messageReceiver = m_globalMessageReceivers.get(messageID.messageClass())) {
        messageReceiver->didReceiveSyncMessage(connection, messageID, argumentDecoder, reply);
        return true;
    }

    return false;
}
开发者ID:gobihun,项目名称:webkit,代码行数:9,代码来源:MessageReceiverMap.cpp

示例5: dispatchMessage

bool MessageReceiverMap::dispatchMessage(Connection* connection, MessageID messageID, ArgumentDecoder* argumentDecoder)
{
    if (MessageReceiver* messageReceiver = m_globalMessageReceivers.get(messageID.messageClass())) {
        messageReceiver->didReceiveMessage(connection, messageID, argumentDecoder);
        return true;
    }

    return false;
}
开发者ID:gobihun,项目名称:webkit,代码行数:9,代码来源:MessageReceiverMap.cpp

示例6: processIncomingMessage

void Connection::processIncomingMessage(MessageID messageID, PassOwnPtr<ArgumentDecoder> arguments)
{
    // Check if this is a sync reply.
    if (messageID == MessageID(CoreIPCMessage::SyncMessageReply)) {
        MutexLocker locker(m_syncReplyStateMutex);
        ASSERT(!m_pendingSyncReplies.isEmpty());

        PendingSyncReply& pendingSyncReply = m_pendingSyncReplies.last();
        ASSERT(pendingSyncReply.syncRequestID == arguments->destinationID());

        pendingSyncReply.replyDecoder = arguments.leakPtr();
        pendingSyncReply.didReceiveReply = true;

        m_waitForSyncReplySemaphore.signal();
        return;
    }

    // Check if this is a sync message. If it is, and we're waiting for a sync reply this message
    // needs to be dispatched. If we don't we'll end up with a deadlock where both sync message senders are
    // stuck waiting for a reply.
    if (messageID.isSync()) {
        MutexLocker locker(m_syncReplyStateMutex);
        if (!m_pendingSyncReplies.isEmpty()) {
            m_syncMessagesReceivedWhileWaitingForSyncReply.append(IncomingMessage(messageID, arguments));

            // The message has been added, now wake up the client thread.
            m_waitForSyncReplySemaphore.signal();
            return;
        }
    }
        
    // Check if we're waiting for this message.
    {
        MutexLocker locker(m_waitForMessageMutex);
        
        HashMap<std::pair<unsigned, uint64_t>, ArgumentDecoder*>::iterator it = m_waitForMessageMap.find(std::make_pair(messageID.toInt(), arguments->destinationID()));
        if (it != m_waitForMessageMap.end()) {
            it->second = arguments.leakPtr();
        
            m_waitForMessageCondition.signal();
            return;
        }
    }

    MutexLocker locker(m_incomingMessagesLock);
    m_incomingMessages.append(IncomingMessage(messageID, arguments));

    m_clientRunLoop->scheduleWork(WorkItem::create(this, &Connection::dispatchMessages));
}
开发者ID:,项目名称:,代码行数:49,代码来源:

示例7: sendOutgoingMessage

bool Connection::sendOutgoingMessage(MessageID messageID, PassOwnPtr<MessageEncoder> encoder)
{
    ASSERT(!m_pendingWriteEncoder);

    // Just bail if the handle has been closed.
    if (m_connectionPipe == INVALID_HANDLE_VALUE)
        return false;

    // We put the message ID last.
    encoder->encode(static_cast<uint32_t>(messageID.toInt()));

    // Write the outgoing message.

    if (::WriteFile(m_connectionPipe, encoder->buffer(), encoder->bufferSize(), 0, &m_writeState)) {
        // We successfully sent this message.
        return true;
    }

    DWORD error = ::GetLastError();

    if (error == ERROR_NO_DATA) {
        // The pipe is being closed.
        connectionDidClose();
        return false;
    }

    if (error != ERROR_IO_PENDING) {
        ASSERT_NOT_REACHED();
        return false;
    }

    // The message will be sent soon. Hold onto the encoder so that it won't be destroyed
    // before the write completes.
    m_pendingWriteEncoder = encoder;

    // We can only send one asynchronous message at a time (see comment in platformCanSendOutgoingMessages).
    return false;
}
开发者ID:dog-god,项目名称:iptv,代码行数:38,代码来源:ConnectionWin.cpp

示例8: knowsHowToHandleMessage

bool MessageReceiverMap::knowsHowToHandleMessage(MessageID messageID) const
{
    return m_globalMessageReceivers.contains(messageID.messageClass());
}
开发者ID:gobihun,项目名称:webkit,代码行数:4,代码来源:MessageReceiverMap.cpp

示例9: shortenMessageID

MessageID shortenMessageID(const MessageID& id)
{
    return id.substr(0, ID_TRIM_LENGTH) + "..." + id.substr(id.length() - ID_TRIM_LENGTH);
}
开发者ID:hallor,项目名称:vasum,代码行数:4,代码来源:types.cpp


注:本文中的MessageID类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。