Quantcast
Channel: Plantronics Developer Connection: Message List
Viewing all articles
Browse latest Browse all 377

Re: is there a deterministic reference counting management for unmanaged clients of SPOKES

$
0
0

Hi WeiChu,

for a better explanation: we have a (unmanaged) Out of Process COM Server which uses SPOKES in the following manner (like your SpokesSDKCOMSample).

imagine, our COM Server exports a Object called "COurServer" which have two methods "Init" and "Dispose" (pseudocode implementation below)

 

class COurServer {

  CComPtr<ISessionCOMManager> m_sessMgr;


  Init() {

    CoCreateInstance(CLSID_SessionComManager, NULL,CLSCTX_LOCAL_SERVER, IID_ISessionCOMManager, (LPVOID*)&m_sessMgr)))

    CComObject<SessionManagerEventSync>::CreateInstance(&sessionMgrEventsSink);

    AtlAdvise(m_sessMgr, sessionMgrEventsSink, __uuidof(ISessionCOMManagerEvents), &_pSinkCookie);

    }


  Dispose() {

    AtlUnadvise (m_sessMgr, __uuidof(ISessionCOMManagerEvents), _pSinkCookie);

    m_sessMgr.Release();

    }

};


an arbitrary client uses the following sequence: (pseudocode)

{

  SmartPtr spOurServer = CreateInstance(COurServer);

  spOurServer.Init();

  spOurServer.Dispose();

} // leaving the scope will (Final)Release our COurServer object


A (standard) Out of Process COM Server terminates if no more object are in use.

But the client above can not control this in a deterministic way (through Dispose/AtlUnadvise) because your Server (PlantronicsURE) kept an reference to the EventSink (SessionManagerEventSync) object and therefore the Process which exports/host the COurServer is still alive.

i assume that you release that reference later on so no leak happens. (but this behavior is not deterministic).


what about these ideas:

  1. i might implement a component using your IPlugin Interface/architekture so i'm responsible for managing references to our object in a deterministic way.
    But so far you mark the IPlugin Interface/architekture as deprecated right?
  2. .Net knows the Dispose pattern, so if you provide an implementation of IDispose which frees all kept references all thing is fine.

 

Thanks in advance

 


Viewing all articles
Browse latest Browse all 377

Trending Articles