Ignore:
Timestamp:
Apr 15, 2019 10:52:16 AM (3 years ago)
Author:
nanang
Message:

Close #2189: fixed PJSUA2 thread safety issue in list of objects manipulation.

File:
1 edited

Legend:

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

    r5672 r5969  
    169169     */ 
    170170    PresenceStatus       presStatus; 
    171      
     171 
    172172public: 
    173173    /** Import from pjsip structure */ 
     
    189189 
    190190/** 
    191  * Buddy. 
     191 * Buddy. This is a lite wrapper class for PJSUA-LIB buddy, i.e: this class 
     192 * only maintains one data member, PJSUA-LIB buddy ID, and the methods are 
     193 * simply proxies for PJSUA-LIB buddy operations. 
     194 * 
     195 * Application can use create() to register a buddy to PJSUA-LIB, and 
     196 * the destructor of the original instance (i.e: the instance that calls 
     197 * create()) will unregister and delete the buddy from PJSUA-LIB. Application 
     198 * must delete all Buddy instances belong to an account before shutting down 
     199 * the account (via Account::shutdown()). 
     200 * 
     201 * The library will not keep a list of Buddy instances, so any Buddy (or 
     202 * descendant) instances instantiated by application must be maintained 
     203 * and destroyed by the application itself. Any PJSUA2 APIs that return Buddy 
     204 * instance(s) such as Account::enumBuddies2() or Account::findBuddy2() will 
     205 * just return generated copy. All Buddy methods should work normally on this 
     206 * generated copy instance. 
    192207 */ 
    193208class Buddy 
     
    200215     
    201216    /** 
    202      * Destructor. Note that if the Buddy instance is deleted, it will also 
    203      * delete the corresponding buddy in the PJSUA-LIB. 
     217     * Destructor. Note that if the Buddy original instance (i.e: the instance 
     218     * that calls Buddy::create()) is destroyed, it will also delete the 
     219     * corresponding buddy in the PJSUA-LIB. While the destructor of 
     220     * a generated copy (i.e: Buddy instance returned by PJSUA2 APIs such as 
     221     * Account::enumBuddies2() or Account::findBuddy2()) will do nothing. 
    204222     */ 
    205223    virtual ~Buddy(); 
     
    207225    /** 
    208226     * Create buddy and register the buddy to PJSUA-LIB. 
     227     * 
     228     * Note that application should maintain the Buddy original instance, i.e: 
     229     * the instance that calls this create() method as it is only the original 
     230     * instance destructor that will delete the underlying Buddy in PJSUA-LIB. 
    209231     * 
    210232     * @param acc               The account for this buddy. 
     
    298320      * Buddy ID. 
    299321      */ 
    300      pjsua_buddy_id      id; 
    301       
    302      /** 
    303       * Account. 
    304       */ 
    305      Account            *acc; 
    306 }; 
    307  
     322    pjsua_buddy_id       id; 
     323 
     324private: 
     325    friend class Endpoint; 
     326    friend class Account; 
     327 
     328    /* Internal constructor/methods used by Endpoint and Account */ 
     329    Buddy(pjsua_buddy_id buddy_id); 
     330    Buddy *getOriginalInstance(); 
     331}; 
     332 
     333 
     334/** 
     335 * Warning: deprecated, use BuddyVector2 instead. 
     336 * 
     337 * Array of buddies. 
     338 */ 
     339typedef std::vector<Buddy*> BuddyVector; 
    308340 
    309341/** Array of buddies */ 
    310 typedef std::vector<Buddy*> BuddyVector; 
     342typedef std::vector<Buddy> BuddyVector2; 
    311343 
    312344 
Note: See TracChangeset for help on using the changeset viewer.