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); } }
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); } } } }
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 } }
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; } }