Changeset 5912


Ignore:
Timestamp:
Nov 22, 2018 2:39:29 AM (6 years ago)
Author:
ming
Message:

Re #2159: Replace std::mutex with PJSIP's own pj_mutex_t, since std::mutex is only available starting C++11

Location:
pjproject/trunk/pjsip
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/include/pjsua2/endpoint.hpp

    r5904 r5912  
    2929#include <list> 
    3030#include <map> 
    31 #include <mutex> 
    3231 
    3332/** PJSUA2 API is inside pj namespace */ 
     
    15981597    CodecInfoVector              videoCodecInfoList; 
    15991598    std::map<pj_thread_t*, pj_thread_desc*> threadDescMap; 
    1600     std::mutex                   threadDescMutex; 
     1599    pj_mutex_t                  *threadDescMutex; 
    16011600 
    16021601    /* Pending logging */ 
  • pjproject/trunk/pjsip/src/pjsua2/endpoint.cpp

    r5904 r5912  
    480480 */ 
    481481Endpoint::Endpoint() 
    482 : writer(NULL), mainThreadOnly(false), mainThread(NULL), pendingJobSize(0) 
     482: writer(NULL), threadDescMutex(NULL), mainThreadOnly(false),  
     483  mainThread(NULL), pendingJobSize(0) 
    483484{ 
    484485    if (instance_) { 
     
    16891690            threadDescMap[t] = NULL; 
    16901691    } 
     1692     
     1693    PJSUA2_CHECK_EXPR( pj_mutex_create_simple(pjsua_var.pool, "threadDesc", 
     1694                                              &threadDescMutex) ); 
    16911695} 
    16921696 
     
    17111715    status = pj_thread_register(name.c_str(), *desc, &thread); 
    17121716    if (status == PJ_SUCCESS) { 
    1713         std::lock_guard<std::mutex> guard(threadDescMutex); 
     1717        pj_mutex_lock(threadDescMutex); 
    17141718        threadDescMap[thread] = desc; 
     1719        pj_mutex_unlock(threadDescMutex); 
    17151720    } else { 
    17161721        free(desc); 
     
    17221727{ 
    17231728    if (pj_thread_is_registered()) { 
    1724         std::lock_guard<std::mutex> guard(threadDescMutex); 
     1729        bool found; 
     1730 
     1731        pj_mutex_lock(threadDescMutex); 
    17251732        /* Recheck again if it exists in the thread description map */ 
    1726         return (threadDescMap.find(pj_thread_this()) != threadDescMap.end()); 
     1733        found = (threadDescMap.find(pj_thread_this()) != threadDescMap.end()); 
     1734        pj_mutex_unlock(threadDescMutex); 
     1735 
     1736        return found; 
    17271737    } 
    17281738 
     
    17441754{ 
    17451755    pj_status_t status; 
     1756 
     1757    if (threadDescMutex) { 
     1758        pj_mutex_destroy(threadDescMutex); 
     1759        threadDescMutex = NULL; 
     1760    } 
    17461761 
    17471762    status = pjsua_destroy2(flags); 
Note: See TracChangeset for help on using the changeset viewer.