00001 00002 // Program Name: upnptaskcache.h 00003 // 00004 // Purpose - UPnp Task to keep SSDPCache free of stale records 00005 // 00006 // Created By : David Blain Created On : Jan. 9, 2007 00007 // Modified By : Modified On: 00008 // 00010 00011 #ifndef __UPNPTASKCACHE_H__ 00012 #define __UPNPTASKCACHE_H__ 00013 00014 #include "upnp.h" 00015 00018 // 00019 // SSDPCacheTask Class Definition 00020 // 00023 00024 class SSDPCacheTask : public Task 00025 { 00026 protected: 00027 00028 int m_nInterval; // Number of ms between executing. 00029 int m_nExecuteCount; // Used for debugging. 00030 00031 // Destructor protected to force use of Release Method 00032 00033 virtual ~SSDPCacheTask() {}; 00034 00035 public: 00036 00037 SSDPCacheTask() 00038 { 00039 m_nExecuteCount = 0; 00040 m_nInterval = UPnp::g_pConfig->GetValue( "UPnP/SSDP/CacheInterval", 30 ) * 1000; 00041 00042 } 00043 00044 virtual QString Name () 00045 { 00046 return( "SSDPCache" ); 00047 } 00048 00049 virtual void Execute( TaskQueue *pQueue ) 00050 { 00051 m_nExecuteCount++; 00052 00053 int nCount = UPnp::g_SSDPCache.RemoveStale(); 00054 00055 if (nCount > 0) 00056 VERBOSE( VB_UPNP, QString( "SSDPCacheTask - Removed %1 stale entries." ).arg( nCount )); 00057 00058 if ((m_nExecuteCount % 60) == 0) 00059 UPnp::g_SSDPCache.Dump(); 00060 00061 pQueue->AddTask( m_nInterval, (Task *)this ); 00062 } 00063 00064 }; 00065 00066 #endif
1.5.5