//*************************************************************************** // // File: // // Module: MS SNMP Provider // // Purpose: // // Copyright (c) 1997-2001 Microsoft Corporation, All Rights Reserved // //*************************************************************************** #include "precomp.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include extern CCorrCacheWrapper* g_CacheWrapper; extern CEventProviderWorkerThread* g_pWorkerThread; CBaseCorrCacheNotify::CBaseCorrCacheNotify() { m_cRef=0; m_dwCookie=0; m_DoWork = TRUE; InitializeCriticalSection ( & m_CriticalSection ) ; } CBaseCorrCacheNotify::~CBaseCorrCacheNotify() { DeleteCriticalSection ( & m_CriticalSection ) ; } void CBaseCorrCacheNotify::Detach() { EnterCriticalSection ( & m_CriticalSection ) ; m_DoWork = FALSE; LeaveCriticalSection ( & m_CriticalSection ) ; } /* * CBaseCorrCacheNotify::QueryInterface * CBaseCorrCacheNotify::AddRef * CBaseCorrCacheNotify::Release * * Purpose: * Non-delegating IUnknown members for CBaseCorrCacheNotify. */ STDMETHODIMP CBaseCorrCacheNotify::QueryInterface(REFIID riid, LPVOID *ppv) { *ppv=NULL; if (IID_IUnknown == riid || IID_ISMIR_Notify == riid) *ppv=this; if (NULL!=*ppv) { ((LPUNKNOWN)*ppv)->AddRef(); return NOERROR; } return ResultFromScode(E_NOINTERFACE); } STDMETHODIMP_(ULONG) CBaseCorrCacheNotify::AddRef() { return ++m_cRef; } STDMETHODIMP_(ULONG) CBaseCorrCacheNotify::Release() { if (0!=--m_cRef) return m_cRef; delete this; return 0; } STDMETHODIMP CCorrCacheNotify::ChangeNotify() { EnterCriticalSection ( & m_CriticalSection ) ; BOOL bDoWork = m_DoWork; LeaveCriticalSection ( & m_CriticalSection ) ; if (bDoWork) { (g_CacheWrapper->GetCache())->InvalidateCache(); CCorrCache* cache = new CCorrCache(); g_CacheWrapper->SetCache(cache); g_CacheWrapper->ReleaseCache(); } return NOERROR; } STDMETHODIMP CEventCacheNotify::ChangeNotify() { EnterCriticalSection ( & m_CriticalSection ) ; BOOL bDoWork = m_DoWork; LeaveCriticalSection ( & m_CriticalSection ) ; if (bDoWork) { g_pWorkerThread->Clear(); } return NOERROR; }