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:
parent
70d51ffc5b
commit
8ca793593d
5 changed files with 32 additions and 13 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue