Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
cd607cb2
Commit
cd607cb2
authored
Dec 28, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib/upnp/Discovery: use std::chrono::steady_clock
parent
4e60ab7f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
13 deletions
+15
-13
Discovery.cxx
src/lib/upnp/Discovery.cxx
+5
-5
Discovery.hxx
src/lib/upnp/Discovery.hxx
+10
-8
No files found.
src/lib/upnp/Discovery.cxx
View file @
cd607cb2
...
...
@@ -20,7 +20,6 @@
#include "config.h"
#include "Discovery.hxx"
#include "ContentDirectoryService.hxx"
#include "system/Clock.hxx"
#include "Log.hxx"
#include "util/ScopeExit.hxx"
#include "util/RuntimeError.hxx"
...
...
@@ -132,7 +131,8 @@ UPnPDeviceDirectory::Explore()
// Update or insert the device
ContentDirectoryDescriptor
d
(
std
::
move
(
tsk
->
device_id
),
MonotonicClockS
(),
tsk
->
expires
);
std
::
chrono
::
steady_clock
::
now
(),
tsk
->
expires
);
try
{
d
.
Parse
(
tsk
->
url
,
buf
);
...
...
@@ -209,7 +209,7 @@ UPnPDeviceDirectory::Invoke(Upnp_EventType et, void *evp)
void
UPnPDeviceDirectory
::
ExpireDevices
()
{
const
unsigned
now
=
MonotonicClockS
();
const
auto
now
=
std
::
chrono
::
steady_clock
::
now
();
bool
didsomething
=
false
;
for
(
auto
it
=
directories
.
begin
();
...
...
@@ -251,8 +251,8 @@ UPnPDeviceDirectory::Start()
void
UPnPDeviceDirectory
::
Search
()
{
const
unsigned
now
=
MonotonicClockS
();
if
(
now
-
last_search
<
10
)
const
auto
now
=
std
::
chrono
::
steady_clock
::
now
();
if
(
now
-
last_search
<
std
::
chrono
::
seconds
(
10
)
)
return
;
last_search
=
now
;
...
...
src/lib/upnp/Discovery.hxx
View file @
cd607cb2
...
...
@@ -32,6 +32,7 @@
#include <vector>
#include <string>
#include <memory>
#include <chrono>
class
ContentDirectoryService
;
...
...
@@ -56,7 +57,7 @@ class UPnPDeviceDirectory final : UpnpCallback {
struct
DiscoveredTask
{
std
::
string
url
;
std
::
string
device_id
;
unsigned
expires
;
// Seconds valid
std
::
chrono
::
steady_clock
::
duration
expires
;
DiscoveredTask
(
const
Upnp_Discovery
*
disco
)
:
url
(
disco
->
Location
),
...
...
@@ -75,16 +76,17 @@ class UPnPDeviceDirectory final : UpnpCallback {
UPnPDevice
device
;
/**
* The MonotonicClockS() time stamp when this device
* expires.
* The time stamp when this device expires.
*/
unsigned
expires
;
std
::
chrono
::
steady_clock
::
time_point
expires
;
ContentDirectoryDescriptor
()
=
default
;
ContentDirectoryDescriptor
(
std
::
string
&&
_id
,
unsigned
last
,
int
exp
)
:
id
(
std
::
move
(
_id
)),
expires
(
last
+
exp
+
20
)
{}
std
::
chrono
::
steady_clock
::
time_point
last
,
std
::
chrono
::
steady_clock
::
duration
exp
)
:
id
(
std
::
move
(
_id
)),
expires
(
last
+
exp
+
std
::
chrono
::
seconds
(
20
))
{}
void
Parse
(
const
std
::
string
&
url
,
const
char
*
description
)
{
device
.
Parse
(
url
,
description
);
...
...
@@ -106,9 +108,9 @@ class UPnPDeviceDirectory final : UpnpCallback {
int
search_timeout
=
2
;
/**
* The
MonotonicClockS()
time stamp of the last search.
* The time stamp of the last search.
*/
unsigned
last_search
=
0
;
std
::
chrono
::
steady_clock
::
time_point
last_search
=
std
::
chrono
::
steady_clock
::
time_point
()
;
public
:
UPnPDeviceDirectory
(
UpnpClient_Handle
_handle
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment