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


C++ PassOwnPtr::buffer方法代码示例

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


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

示例1: 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,代码来源:

示例2: 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


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