提交 c24dbb29 authored 作者: Nazar Mokrynskyi's avatar Nazar Mokrynskyi

Minor cleanup

上级 6868bd27
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
/* Static. */ /* Static. */
static constexpr size_t CheckerInterval{ 10u }; // In ms. static constexpr size_t CheckerInterval{ 10u }; // In ms.
static std::mutex globalSyncMutex; static std::mutex GlobalSyncMutex;
static size_t globalInstances = 0; static size_t GlobalInstances{ 0u };
/* Static methods for usrsctp global callbacks. */ /* Static methods for usrsctp global callbacks. */
...@@ -65,10 +65,9 @@ void DepUsrSCTP::ClassInit() ...@@ -65,10 +65,9 @@ void DepUsrSCTP::ClassInit()
MS_DEBUG_TAG(info, "usrsctp"); MS_DEBUG_TAG(info, "usrsctp");
{ std::lock_guard<std::mutex> lock(GlobalSyncMutex);
std::lock_guard<std::mutex> lock(globalSyncMutex);
if (globalInstances == 0) if (GlobalInstances == 0)
{ {
usrsctp_init_nothreads(0, onSendSctpData, sctpDebug); usrsctp_init_nothreads(0, onSendSctpData, sctpDebug);
...@@ -80,19 +79,17 @@ void DepUsrSCTP::ClassInit() ...@@ -80,19 +79,17 @@ void DepUsrSCTP::ClassInit()
#endif #endif
} }
++globalInstances; ++GlobalInstances;
}
} }
void DepUsrSCTP::ClassDestroy() void DepUsrSCTP::ClassDestroy()
{ {
MS_TRACE(); MS_TRACE();
{ std::lock_guard<std::mutex> lock(GlobalSyncMutex);
std::lock_guard<std::mutex> lock(globalSyncMutex); --GlobalInstances;
--globalInstances;
if (globalInstances == 0) if (GlobalInstances == 0)
{ {
usrsctp_finish(); usrsctp_finish();
...@@ -101,7 +98,6 @@ void DepUsrSCTP::ClassDestroy() ...@@ -101,7 +98,6 @@ void DepUsrSCTP::ClassDestroy()
DepUsrSCTP::mapIdSctpAssociation.clear(); DepUsrSCTP::mapIdSctpAssociation.clear();
} }
}
} }
void DepUsrSCTP::CreateChecker() void DepUsrSCTP::CreateChecker()
...@@ -126,7 +122,7 @@ uintptr_t DepUsrSCTP::GetNextSctpAssociationId() ...@@ -126,7 +122,7 @@ uintptr_t DepUsrSCTP::GetNextSctpAssociationId()
{ {
MS_TRACE(); MS_TRACE();
std::lock_guard<std::mutex> lock(globalSyncMutex); std::lock_guard<std::mutex> lock(GlobalSyncMutex);
// NOTE: usrsctp_connect() fails with a value of 0. // NOTE: usrsctp_connect() fails with a value of 0.
if (DepUsrSCTP::nextSctpAssociationId == 0u) if (DepUsrSCTP::nextSctpAssociationId == 0u)
...@@ -150,7 +146,7 @@ void DepUsrSCTP::RegisterSctpAssociation(RTC::SctpAssociation* sctpAssociation) ...@@ -150,7 +146,7 @@ void DepUsrSCTP::RegisterSctpAssociation(RTC::SctpAssociation* sctpAssociation)
{ {
MS_TRACE(); MS_TRACE();
std::lock_guard<std::mutex> lock(globalSyncMutex); std::lock_guard<std::mutex> lock(GlobalSyncMutex);
MS_ASSERT(DepUsrSCTP::checker != nullptr, "Checker not created"); MS_ASSERT(DepUsrSCTP::checker != nullptr, "Checker not created");
...@@ -170,7 +166,7 @@ void DepUsrSCTP::DeregisterSctpAssociation(RTC::SctpAssociation* sctpAssociation ...@@ -170,7 +166,7 @@ void DepUsrSCTP::DeregisterSctpAssociation(RTC::SctpAssociation* sctpAssociation
{ {
MS_TRACE(); MS_TRACE();
std::lock_guard<std::mutex> lock(globalSyncMutex); std::lock_guard<std::mutex> lock(GlobalSyncMutex);
MS_ASSERT(DepUsrSCTP::checker != nullptr, "Checker not created"); MS_ASSERT(DepUsrSCTP::checker != nullptr, "Checker not created");
...@@ -187,7 +183,7 @@ RTC::SctpAssociation* DepUsrSCTP::RetrieveSctpAssociation(uintptr_t id) ...@@ -187,7 +183,7 @@ RTC::SctpAssociation* DepUsrSCTP::RetrieveSctpAssociation(uintptr_t id)
{ {
MS_TRACE(); MS_TRACE();
std::lock_guard<std::mutex> lock(globalSyncMutex); std::lock_guard<std::mutex> lock(GlobalSyncMutex);
auto it = DepUsrSCTP::mapIdSctpAssociation.find(id); auto it = DepUsrSCTP::mapIdSctpAssociation.find(id);
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论