1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

RTC: Refactor code.

This commit is contained in:
winlin 2020-06-02 19:00:31 +08:00
parent 70d51ffc5b
commit 8ca793593d
5 changed files with 32 additions and 13 deletions

View file

@ -27,6 +27,7 @@
#include <srs_kernel_log.hpp>
#include <vector>
#include <algorithm>
using namespace std;
SrsCoroutineManager::SrsCoroutineManager()
@ -72,7 +73,9 @@ srs_error_t SrsCoroutineManager::cycle()
void SrsCoroutineManager::remove(ISrsConnection* c)
{
conns.push_back(c);
if (::find(conns.begin(), conns.end(), c) == conns.end()) {
conns.push_back(c);
}
srs_cond_signal(cond);
}
@ -80,8 +83,8 @@ void SrsCoroutineManager::clear()
{
// To prevent thread switch when delete connection,
// we copy all connections then free one by one.
vector<ISrsConnection*> copy = conns;
conns.clear();
vector<ISrsConnection*> copy;
copy.swap(conns);
vector<ISrsConnection*>::iterator it;
for (it = copy.begin(); it != copy.end(); ++it) {