예제 #1
0
void MultiplexedSocket::ioReactorThreadPauseSend(const MultiplexedSocketWPtr& weak_thus, Stream::StreamID sid) {
    MultiplexedSocketPtr thus(weak_thus.lock());
    if (thus) {
        static Stream::StreamID::Hasher hasher;
        SerializationCheck::Scoped ss(thus.get());
        size_t whichStream=hasher(sid)%thus->mSockets.size();
        thus->mSockets[whichStream].ioReactorThreadPauseStream(thus, sid);
    }
}
예제 #2
0
void MultiplexedSocket::ioReactorThreadResumeRead(const MultiplexedSocketWPtr& weak_thus, Stream::StreamID sid){
    MultiplexedSocketPtr thus(weak_thus.lock());
    if (thus) {
        SerializationCheck::Scoped ss(thus.get());
        for (std::vector<ASIOSocketWrapper>::iterator i=thus->mSockets.begin(),ie=thus->mSockets.end();i!=ie;++i) {
            if (i->getReadBuffer()) {
                i->getReadBuffer()->ioReactorThreadResumeRead(thus);
            }
        }
    }
}
예제 #3
0
void ASIOReadBuffer::asioReadIntoFixedBuffer(const ErrorCode&error,std::size_t bytes_read) {
    TCPSSTLOG(this,"rcv",&mBuffer[mBufferPos],bytes_read,error);
    mBufferPos+=bytes_read;
    std::tr1::shared_ptr<MultiplexedSocket> thus(mParentSocket.lock());

    if (thus) {
        if (error) {
            processError(&*thus,error);
        } else {
            translateBuffer(thus);
        }
    } else {
        delete this;// the socket is deleted
    }
}
예제 #4
0
void ASIOReadBuffer::asioReadIntoChunk(const ErrorCode&error,std::size_t bytes_read) {
    TCPSSTLOG(this,"rcv",&mNewChunk[mBufferPos],bytes_read,error);
    mBufferPos+=bytes_read;
    std::tr1::shared_ptr<MultiplexedSocket> thus(mParentSocket.lock());

    if (thus) {
        if (error) {
            processError(&*thus,error);
        } else {
            if (mBufferPos>=mNewChunk.size()) {
                assert(mBufferPos==mNewChunk.size());
                processFullChunk(thus,mWhichBuffer,mNewChunkID,mNewChunk);
                mNewChunk.resize(0);
                mBufferPos=0;
                readIntoFixedBuffer(thus);
            } else {
                readIntoChunk(thus);
            }
        }
    } else {
        delete this;
    }
}