mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-13 11:41:44 +08:00
通过减少线程切换提高服务器性能
This commit is contained in:
@@ -232,7 +232,7 @@ inline bool HttpSession::checkLiveFlvStream(){
|
||||
(*this) << SocketFlags(kSockFlags);
|
||||
|
||||
try{
|
||||
start(mediaSrc);
|
||||
start(getPoller(),mediaSrc);
|
||||
}catch (std::exception &ex){
|
||||
//该rtmp源不存在
|
||||
shutdown();
|
||||
@@ -683,36 +683,21 @@ inline void HttpSession::sendNotFound(bool bClose) {
|
||||
|
||||
|
||||
void HttpSession::onWrite(const Buffer::Ptr &buffer) {
|
||||
weak_ptr<HttpSession> weakSelf = dynamic_pointer_cast<HttpSession>(shared_from_this());
|
||||
async([weakSelf,buffer](){
|
||||
auto strongSelf = weakSelf.lock();
|
||||
if(!strongSelf) {
|
||||
return;
|
||||
}
|
||||
strongSelf->_ticker.resetTime();
|
||||
strongSelf->_ui64TotalBytes += buffer->size();
|
||||
strongSelf->send(buffer);
|
||||
});
|
||||
_ticker.resetTime();
|
||||
_ui64TotalBytes += buffer->size();
|
||||
send(buffer);
|
||||
}
|
||||
|
||||
void HttpSession::onWrite(const char *data, int len) {
|
||||
BufferRaw::Ptr buffer(new BufferRaw);
|
||||
buffer->assign(data,len);
|
||||
|
||||
weak_ptr<HttpSession> weakSelf = dynamic_pointer_cast<HttpSession>(shared_from_this());
|
||||
async([weakSelf,buffer](){
|
||||
auto strongSelf = weakSelf.lock();
|
||||
if(!strongSelf) {
|
||||
return;
|
||||
}
|
||||
strongSelf->_ticker.resetTime();
|
||||
strongSelf->_ui64TotalBytes += buffer->size();
|
||||
strongSelf->send(buffer);
|
||||
});
|
||||
_ticker.resetTime();
|
||||
_ui64TotalBytes += buffer->size();
|
||||
send(buffer);
|
||||
}
|
||||
|
||||
void HttpSession::onDetach() {
|
||||
safeShutdown();
|
||||
shutdown();
|
||||
}
|
||||
|
||||
std::shared_ptr<FlvMuxer> HttpSession::getSharedPtr(){
|
||||
|
||||
Reference in New Issue
Block a user