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

SRT: Refine the lock for log.

This commit is contained in:
winlin 2022-06-14 19:13:14 +08:00
parent 910b5945af
commit 0957cdb944
9 changed files with 88 additions and 90 deletions

View file

@ -26,6 +26,7 @@
#include <srs_app_srt_source.hpp>
#endif
#include <stdlib.h>
#include <string>
using namespace std;
@ -427,3 +428,38 @@ srs_error_t srs_thread_initialize()
return err;
}
SrsMutex::SrsMutex()
{
int rc = pthread_mutex_init(&mutex_, NULL);
srs_assert(!rc);
}
SrsMutex::~SrsMutex()
{
int rc = pthread_mutex_destroy(&mutex_);
srs_assert(!rc);
}
void SrsMutex::lock()
{
int rc = pthread_mutex_lock(&mutex_);
srs_assert(!rc);
}
void SrsMutex::unlock()
{
int rc = pthread_mutex_unlock(&mutex_);
srs_assert(!rc);
}
SrsAutoLock::SrsAutoLock(SrsMutex* mutex)
{
mutex_ = mutex;
mutex_->lock();
}
SrsAutoLock::~SrsAutoLock()
{
mutex_->unlock();
}