MythTV  master
upnptaskcache.h
Go to the documentation of this file.
1 // Program Name: upnptaskcache.h
3 // Created : Jan. 9, 2007
4 //
5 // Purpose : UPnp Task to keep SSDPCache free of stale records
6 //
7 // Copyright (c) 2007 David Blain <dblain@mythtv.org>
8 //
9 // Licensed under the GPL v2 or later, see COPYING for details
10 //
12 
13 #ifndef __UPNPTASKCACHE_H__
14 #define __UPNPTASKCACHE_H__
15 
16 #include <QString>
17 
18 #include "mythlogging.h"
19 #include "upnp.h"
20 
23 //
24 // SSDPCacheTask Class Definition
25 //
28 
29 class SSDPCacheTask : public Task
30 {
31  protected:
32 
33  int m_nInterval; // Number of ms between executing.
34  int m_nExecuteCount; // Used for debugging.
35 
36  // Destructor protected to force use of Release Method
37 
38  ~SSDPCacheTask() override = default;
39 
40  public:
41 
42  SSDPCacheTask() : Task("SSDPCacheTask")
43  {
44  m_nExecuteCount = 0;
45  m_nInterval = 1000 *
46  UPnp::GetConfiguration()->GetValue("UPnP/SSDP/CacheInterval", 30);
47  }
48 
49  QString Name() override // Task
50  {
51  return( "SSDPCache" );
52  }
53 
54  void Execute( TaskQueue *pQueue ) override // Task
55  {
57 
58  int nCount = SSDPCache::Instance()->RemoveStale();
59 
60  if (nCount > 0)
61  {
62  LOG(VB_UPNP, LOG_INFO,
63  QString("SSDPCacheTask - Removed %1 stale entries.")
64  .arg(nCount));
65  }
66 
67  if ((m_nExecuteCount % 60) == 0)
69 
70  pQueue->AddTask( m_nInterval, (Task *)this );
71  }
72 
73 };
74 
75 #endif
int RemoveStale()
Definition: ssdpcache.cpp:450
static SSDPCache * Instance()
Definition: ssdpcache.cpp:236
virtual int GetValue(const QString &sSetting, int Default)=0
void Execute(TaskQueue *pQueue) override
Definition: upnptaskcache.h:54
void Dump(void)
Prints this device to the console in a human readable form.
Definition: ssdpcache.cpp:577
QString Name() override
Definition: upnptaskcache.h:49
static Configuration * GetConfiguration()
Definition: upnp.cpp:71
#define LOG(_MASK_, _LEVEL_, _STRING_)
Definition: mythlogging.h:41
Definition: taskqueue.h:53
~SSDPCacheTask() override=default