MythTV
master
mythtv
libs
libmythupnp
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 LICENSE for details
10
//
12
13
#ifndef UPNPTASKCACHE_H
14
#define UPNPTASKCACHE_H
15
16
#include <QString>
17
18
#include "
libmythbase/mythlogging.h
"
19
20
#include "
libmythupnp/upnp.h
"
21
24
//
25
// SSDPCacheTask Class Definition
26
//
29
30
class
SSDPCacheTask
:
public
Task
31
{
32
protected
:
33
34
std::chrono::milliseconds
m_nInterval
{30s};
// Number of ms between executing.
35
int
m_nExecuteCount
{0};
// Used for debugging.
36
37
// Destructor protected to force use of Release Method
38
39
~SSDPCacheTask
()
override
=
default
;
40
41
public
:
42
43
SSDPCacheTask
() :
Task
(
"SSDPCacheTask"
)
44
{
45
m_nInterval
= 30s;
46
// TODO: Rework when separating upnp/ssdp stack
47
// XmlConfiguration().GetDuration<std::chrono::seconds>("UPnP/SSDP/CacheInterval", 30s);
48
}
49
50
QString
Name
() override
// Task
51
{
52
return
(
"SSDPCache"
);
53
}
54
55
void
Execute
(
TaskQueue
*pQueue )
override
// Task
56
{
57
m_nExecuteCount
++;
58
59
int
nCount =
SSDPCache::Instance
()->
RemoveStale
();
60
61
if
(nCount > 0)
62
{
63
LOG
(VB_UPNP, LOG_INFO,
64
QString(
"SSDPCacheTask - Removed %1 stale entries."
)
65
.arg(nCount));
66
}
67
68
if
((
m_nExecuteCount
% 60) == 0)
69
SSDPCache::Instance
()->
Dump
();
70
71
pQueue->AddTask(
m_nInterval
, (
Task
*)
this
);
72
}
73
74
};
75
76
#endif // UPNPTASKCACHE_H
SSDPCacheTask::m_nExecuteCount
int m_nExecuteCount
Definition:
upnptaskcache.h:35
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition:
mythlogging.h:39
SSDPCacheTask::SSDPCacheTask
SSDPCacheTask()
Definition:
upnptaskcache.h:43
SSDPCache::Instance
static SSDPCache * Instance()
Definition:
ssdpcache.cpp:237
TaskQueue
Definition:
taskqueue.h:82
SSDPCacheTask::Name
QString Name() override
Definition:
upnptaskcache.h:50
upnp.h
mythlogging.h
SSDPCacheTask
Definition:
upnptaskcache.h:30
Task
Definition:
taskqueue.h:54
SSDPCache::RemoveStale
int RemoveStale()
Definition:
ssdpcache.cpp:451
SSDPCache::Dump
void Dump(void)
Prints this device to the console in a human readable form.
Definition:
ssdpcache.cpp:577
SSDPCacheTask::m_nInterval
std::chrono::milliseconds m_nInterval
Definition:
upnptaskcache.h:34
SSDPCacheTask::~SSDPCacheTask
~SSDPCacheTask() override=default
SSDPCacheTask::Execute
void Execute(TaskQueue *pQueue) override
Definition:
upnptaskcache.h:55
Generated on Tue Jan 7 2025 03:18:37 for MythTV by
1.8.17