Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
73b6ea42
Commit
73b6ea42
authored
Oct 24, 2022
by
Pavel Vainerman
Committed by
Pavel Vainerman
Oct 24, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(timers): used steady_clock instead high_resolution_clock
parent
4ed50544
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
27 additions
and
24 deletions
+27
-24
UNetReceiver.cc
extensions/UNetUDP/UNetReceiver.cc
+5
-5
UNetReceiver.h
extensions/UNetUDP/UNetReceiver.h
+3
-3
unet-multicast-tester.cc
extensions/UNetUDP/unet-multicast-tester.cc
+2
-2
unet-udp-tester.cc
extensions/UNetUDP/unet-udp-tester.cc
+2
-2
PassiveTimer.h
include/PassiveTimer.h
+1
-1
TCPCheck.cc
src/Communications/TCP/TCPCheck.cc
+2
-2
UniSetActivator.cc
src/Core/UniSetActivator.cc
+1
-1
CommonEventLoop.cc
src/Processes/CommonEventLoop.cc
+2
-2
EventLoopServer.cc
src/Processes/EventLoopServer.cc
+1
-1
PassiveCondTimer.cc
src/Timers/PassiveCondTimer.cc
+5
-2
PassiveSigTimer.cc
src/Timers/PassiveSigTimer.cc
+0
-0
PassiveTimer.cc
src/Timers/PassiveTimer.cc
+3
-3
WaitingPassiveTimer.cc
src/Timers/WaitingPassiveTimer.cc
+0
-0
No files found.
extensions/UNetUDP/UNetReceiver.cc
View file @
73b6ea42
...
@@ -314,7 +314,7 @@ void UNetReceiver::statisticsEvent(ev::periodic& tm, int revents) noexcept
...
@@ -314,7 +314,7 @@ void UNetReceiver::statisticsEvent(ev::periodic& tm, int revents) noexcept
return
;
return
;
}
}
t_end
=
chrono
::
high_resolution
_clock
::
now
();
t_end
=
chrono
::
steady
_clock
::
now
();
float
sec
=
chrono
::
duration_cast
<
chrono
::
duration
<
float
>>
(
t_end
-
t_stats
).
count
();
float
sec
=
chrono
::
duration_cast
<
chrono
::
duration
<
float
>>
(
t_end
-
t_stats
).
count
();
t_stats
=
t_end
;
t_stats
=
t_end
;
stats
.
recvPerSec
=
recvCount
/
sec
;
stats
.
recvPerSec
=
recvCount
/
sec
;
...
@@ -537,7 +537,7 @@ void UNetReceiver::readEvent( ev::io& watcher ) noexcept
...
@@ -537,7 +537,7 @@ void UNetReceiver::readEvent( ev::io& watcher ) noexcept
return
;
return
;
bool
ok
=
false
;
bool
ok
=
false
;
t_start
=
chrono
::
high_resolution
_clock
::
now
();
t_start
=
chrono
::
steady
_clock
::
now
();
try
try
{
{
...
@@ -564,7 +564,7 @@ void UNetReceiver::readEvent( ev::io& watcher ) noexcept
...
@@ -564,7 +564,7 @@ void UNetReceiver::readEvent( ev::io& watcher ) noexcept
ptRecvTimeout
.
reset
();
ptRecvTimeout
.
reset
();
}
}
t_end
=
chrono
::
high_resolution
_clock
::
now
();
t_end
=
chrono
::
steady
_clock
::
now
();
stats
.
recvProcessingTime_microsec
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
t_end
-
t_start
).
count
();
stats
.
recvProcessingTime_microsec
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
t_end
-
t_start
).
count
();
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
...
@@ -621,7 +621,7 @@ void UNetReceiver::updateEvent( ev::periodic& tm, int revents ) noexcept
...
@@ -621,7 +621,7 @@ void UNetReceiver::updateEvent( ev::periodic& tm, int revents ) noexcept
bool
recvOk
=
checkConnection
();
bool
recvOk
=
checkConnection
();
// обновление данных в SM
// обновление данных в SM
t_start
=
chrono
::
high_resolution
_clock
::
now
();
t_start
=
chrono
::
steady
_clock
::
now
();
try
try
{
{
...
@@ -632,7 +632,7 @@ void UNetReceiver::updateEvent( ev::periodic& tm, int revents ) noexcept
...
@@ -632,7 +632,7 @@ void UNetReceiver::updateEvent( ev::periodic& tm, int revents ) noexcept
unetcrit
<<
myname
<<
"(updateEvent): "
<<
ex
.
what
()
<<
std
::
endl
;
unetcrit
<<
myname
<<
"(updateEvent): "
<<
ex
.
what
()
<<
std
::
endl
;
}
}
t_end
=
chrono
::
high_resolution
_clock
::
now
();
t_end
=
chrono
::
steady
_clock
::
now
();
stats
.
upProcessingTime_microsec
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
t_end
-
t_start
).
count
();
stats
.
upProcessingTime_microsec
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
t_end
-
t_start
).
count
();
if
(
sidRespond
!=
DefaultObjectId
)
if
(
sidRespond
!=
DefaultObjectId
)
...
...
extensions/UNetUDP/UNetReceiver.h
View file @
73b6ea42
...
@@ -218,9 +218,9 @@ namespace uniset
...
@@ -218,9 +218,9 @@ namespace uniset
// счётчики для подсчёта статистики
// счётчики для подсчёта статистики
size_t
recvCount
=
{
0
};
size_t
recvCount
=
{
0
};
size_t
upCount
=
{
0
};
size_t
upCount
=
{
0
};
std
::
chrono
::
s
ystem
_clock
::
time_point
t_start
;
std
::
chrono
::
s
teady
_clock
::
time_point
t_start
;
std
::
chrono
::
s
ystem
_clock
::
time_point
t_end
;
std
::
chrono
::
s
teady
_clock
::
time_point
t_end
;
std
::
chrono
::
s
ystem
_clock
::
time_point
t_stats
;
std
::
chrono
::
s
teady
_clock
::
time_point
t_stats
;
// текущая статистика
// текущая статистика
struct
Stats
struct
Stats
...
...
extensions/UNetUDP/unet-multicast-tester.cc
View file @
73b6ea42
...
@@ -277,7 +277,7 @@ int main(int argc, char* argv[])
...
@@ -277,7 +277,7 @@ int main(int argc, char* argv[])
if
(
ncycles
>
0
)
if
(
ncycles
>
0
)
nc
=
ncycles
;
nc
=
ncycles
;
auto
t_start
=
high_resolution
_clock
::
now
();
auto
t_start
=
steady
_clock
::
now
();
unsigned
int
npack
=
0
;
unsigned
int
npack
=
0
;
...
@@ -287,7 +287,7 @@ int main(int argc, char* argv[])
...
@@ -287,7 +287,7 @@ int main(int argc, char* argv[])
{
{
if
(
nprof
>
0
&&
npack
>=
nprof
)
if
(
nprof
>
0
&&
npack
>=
nprof
)
{
{
auto
t_end
=
high_resolution
_clock
::
now
();
auto
t_end
=
steady
_clock
::
now
();
float
sec
=
duration_cast
<
duration
<
float
>>
(
t_end
-
t_start
).
count
();
float
sec
=
duration_cast
<
duration
<
float
>>
(
t_end
-
t_start
).
count
();
cout
<<
"Receive "
<<
setw
(
5
)
<<
npack
<<
" packets for "
<<
setw
(
8
)
<<
sec
<<
" sec "
cout
<<
"Receive "
<<
setw
(
5
)
<<
npack
<<
" packets for "
<<
setw
(
8
)
<<
sec
<<
" sec "
<<
" [ 1 packet per "
<<
setw
(
10
)
<<
(
sec
/
(
float
)
npack
)
<<
" sec ]"
<<
endl
;
<<
" [ 1 packet per "
<<
setw
(
10
)
<<
(
sec
/
(
float
)
npack
)
<<
" sec ]"
<<
endl
;
...
...
extensions/UNetUDP/unet-udp-tester.cc
View file @
73b6ea42
...
@@ -229,7 +229,7 @@ int main(int argc, char* argv[])
...
@@ -229,7 +229,7 @@ int main(int argc, char* argv[])
if
(
ncycles
>
0
)
if
(
ncycles
>
0
)
nc
=
ncycles
;
nc
=
ncycles
;
auto
t_start
=
high_resolution
_clock
::
now
();
auto
t_start
=
steady
_clock
::
now
();
unsigned
int
npack
=
0
;
unsigned
int
npack
=
0
;
...
@@ -239,7 +239,7 @@ int main(int argc, char* argv[])
...
@@ -239,7 +239,7 @@ int main(int argc, char* argv[])
{
{
if
(
nprof
>
0
&&
npack
>=
nprof
)
if
(
nprof
>
0
&&
npack
>=
nprof
)
{
{
auto
t_end
=
high_resolution
_clock
::
now
();
auto
t_end
=
steady
_clock
::
now
();
float
sec
=
duration_cast
<
duration
<
float
>>
(
t_end
-
t_start
).
count
();
float
sec
=
duration_cast
<
duration
<
float
>>
(
t_end
-
t_start
).
count
();
cout
<<
"Receive "
<<
setw
(
5
)
<<
npack
<<
" packets for "
<<
setw
(
8
)
<<
sec
<<
" sec "
cout
<<
"Receive "
<<
setw
(
5
)
<<
npack
<<
" packets for "
<<
setw
(
8
)
<<
sec
<<
" sec "
<<
" [ 1 packet per "
<<
setw
(
10
)
<<
(
sec
/
(
float
)
npack
)
<<
" sec ]"
<<
endl
;
<<
" [ 1 packet per "
<<
setw
(
10
)
<<
(
sec
/
(
float
)
npack
)
<<
" sec ]"
<<
endl
;
...
...
include/PassiveTimer.h
View file @
73b6ea42
...
@@ -118,7 +118,7 @@ namespace uniset
...
@@ -118,7 +118,7 @@ namespace uniset
// отделяем внутреннее (теперь уже стандартное >= c++11)
// отделяем внутреннее (теперь уже стандартное >= c++11)
// представление для работы со временем (std::chrono)
// представление для работы со временем (std::chrono)
// и тип (t_msec) для "пользователей"
// и тип (t_msec) для "пользователей"
std
::
chrono
::
high_resolution
_clock
::
time_point
t_start
;
/*!< время установки таймера (сброса) */
std
::
chrono
::
steady
_clock
::
time_point
t_start
;
/*!< время установки таймера (сброса) */
std
::
chrono
::
milliseconds
t_inner_msec
;
/*!< время установки таймера, мсек (в единицах std::chrono) */
std
::
chrono
::
milliseconds
t_inner_msec
;
/*!< время установки таймера, мсек (в единицах std::chrono) */
private
:
private
:
...
...
src/Communications/TCP/TCPCheck.cc
View file @
73b6ea42
...
@@ -63,7 +63,7 @@ namespace uniset
...
@@ -63,7 +63,7 @@ namespace uniset
do
do
{
{
status
=
future
.
wait_
for
(
std
::
chrono
::
milliseconds
(
tout_msec
));
status
=
future
.
wait_
until
(
std
::
chrono
::
steady_clock
::
now
()
+
std
::
chrono
::
milliseconds
(
tout_msec
));
if
(
status
==
std
::
future_status
::
timeout
)
if
(
status
==
std
::
future_status
::
timeout
)
return
false
;
return
false
;
...
@@ -99,7 +99,7 @@ namespace uniset
...
@@ -99,7 +99,7 @@ namespace uniset
do
do
{
{
status
=
future
.
wait_
for
(
std
::
chrono
::
milliseconds
(
tout_msec
));
status
=
future
.
wait_
until
(
std
::
chrono
::
steady_clock
::
now
()
+
std
::
chrono
::
milliseconds
(
tout_msec
));
if
(
status
==
std
::
future_status
::
timeout
)
if
(
status
==
std
::
future_status
::
timeout
)
return
false
;
return
false
;
...
...
src/Core/UniSetActivator.cc
View file @
73b6ea42
...
@@ -297,7 +297,7 @@ namespace uniset
...
@@ -297,7 +297,7 @@ namespace uniset
ulogsys
<<
"(FINISH GUARD THREAD): wait "
<<
TERMINATE_TIMEOUT_SEC
<<
" sec.."
<<
endl
<<
flush
;
ulogsys
<<
"(FINISH GUARD THREAD): wait "
<<
TERMINATE_TIMEOUT_SEC
<<
" sec.."
<<
endl
<<
flush
;
g_doneevent
.
wait_
for
(
lk
,
std
::
chrono
::
milliseconds
(
TERMINATE_TIMEOUT_SEC
*
1000
),
[]()
g_doneevent
.
wait_
until
(
lk
,
std
::
chrono
::
steady_clock
::
now
()
+
std
::
chrono
::
milliseconds
(
TERMINATE_TIMEOUT_SEC
*
1000
),
[]()
{
{
return
(
g_done
==
true
);
return
(
g_done
==
true
);
}
);
}
);
...
...
src/Processes/CommonEventLoop.cc
View file @
73b6ea42
...
@@ -46,7 +46,7 @@ namespace uniset
...
@@ -46,7 +46,7 @@ namespace uniset
thr
=
unisetstd
::
make_unique
<
std
::
thread
>
(
[
&
]
{
CommonEventLoop
::
defaultLoop
();
}
);
thr
=
unisetstd
::
make_unique
<
std
::
thread
>
(
[
&
]
{
CommonEventLoop
::
defaultLoop
();
}
);
std
::
unique_lock
<
std
::
mutex
>
lock2
(
looprunOK_mutex
);
std
::
unique_lock
<
std
::
mutex
>
lock2
(
looprunOK_mutex
);
looprunOK_event
.
wait_
for
(
lock2
,
std
::
chrono
::
milliseconds
(
waitTimeout_msec
),
[
&
]()
looprunOK_event
.
wait_
until
(
lock2
,
std
::
chrono
::
steady_clock
::
now
()
+
std
::
chrono
::
milliseconds
(
waitTimeout_msec
),
[
&
]()
{
{
return
(
isrunning
==
true
);
return
(
isrunning
==
true
);
}
);
}
);
...
@@ -70,7 +70,7 @@ namespace uniset
...
@@ -70,7 +70,7 @@ namespace uniset
evprep
.
send
();
// будим default loop
evprep
.
send
();
// будим default loop
// ожидаем обработки evprepare (которая будет в defaultLoop)
// ожидаем обработки evprepare (которая будет в defaultLoop)
prep_event
.
wait_
for
(
locker
,
std
::
chrono
::
milliseconds
(
waitTimeout_msec
),
[
=
]()
prep_event
.
wait_
until
(
locker
,
std
::
chrono
::
steady_clock
::
now
()
+
std
::
chrono
::
milliseconds
(
waitTimeout_msec
),
[
=
]()
{
{
return
(
prep_notify
==
true
);
return
(
prep_notify
==
true
);
}
);
}
);
...
...
src/Processes/EventLoopServer.cc
View file @
73b6ea42
...
@@ -171,7 +171,7 @@ namespace uniset
...
@@ -171,7 +171,7 @@ namespace uniset
return
true
;
return
true
;
std
::
unique_lock
<
std
::
mutex
>
lock
(
looprunOK_mutex
);
std
::
unique_lock
<
std
::
mutex
>
lock
(
looprunOK_mutex
);
looprunOK_event
.
wait_
for
(
lock
,
std
::
chrono
::
milliseconds
(
waitTimeout_msec
),
[
&
]()
looprunOK_event
.
wait_
until
(
lock
,
std
::
chrono
::
steady_clock
::
now
()
+
std
::
chrono
::
milliseconds
(
waitTimeout_msec
),
[
&
]()
{
{
return
(
isrunning
==
true
);
return
(
isrunning
==
true
);
}
);
}
);
...
...
src/Timers/PassiveCondTimer.cc
View file @
73b6ea42
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
#include <sstream>
#include <sstream>
#include <time.h>
#include <time.h>
#include "PassiveTimer.h"
#include "PassiveTimer.h"
#include <iostream>
// ------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------
using
namespace
std
;
using
namespace
std
;
// ------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------
...
@@ -66,10 +67,12 @@ namespace uniset
...
@@ -66,10 +67,12 @@ namespace uniset
cv_working
.
wait
(
lk
);
cv_working
.
wait
(
lk
);
}
}
else
else
cv_working
.
wait_for
(
lk
,
std
::
chrono
::
milliseconds
(
t_msec
),
[
&
]()
{
cv_working
.
wait_until
(
lk
,
std
::
chrono
::
steady_clock
::
now
()
+
std
::
chrono
::
milliseconds
(
t_msec
),
[
&
]()
{
{
return
(
terminated
==
true
);
return
(
terminated
==
true
);
}
);
});
}
terminated
=
true
;
terminated
=
true
;
return
true
;
return
true
;
...
...
src/Timers/PassiveSigTimer.cc
View file @
73b6ea42
src/Timers/PassiveTimer.cc
View file @
73b6ea42
...
@@ -51,7 +51,7 @@ namespace uniset
...
@@ -51,7 +51,7 @@ namespace uniset
if
(
t_msec
==
0
)
if
(
t_msec
==
0
)
return
true
;
return
true
;
return
(
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
std
::
chrono
::
high_resolution
_clock
::
now
()
-
t_start
).
count
()
>=
t_inner_msec
.
count
()
);
return
(
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
std
::
chrono
::
steady
_clock
::
now
()
-
t_start
).
count
()
>=
t_inner_msec
.
count
()
);
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
...
@@ -72,13 +72,13 @@ namespace uniset
...
@@ -72,13 +72,13 @@ namespace uniset
// Запустить таймер
// Запустить таймер
void
PassiveTimer
::
reset
(
void
)
noexcept
void
PassiveTimer
::
reset
(
void
)
noexcept
{
{
t_start
=
std
::
chrono
::
high_resolution
_clock
::
now
();
t_start
=
std
::
chrono
::
steady
_clock
::
now
();
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// получить текущее значение таймера
// получить текущее значение таймера
timeout_t
PassiveTimer
::
getCurrent
()
const
noexcept
timeout_t
PassiveTimer
::
getCurrent
()
const
noexcept
{
{
return
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
std
::
chrono
::
high_resolution
_clock
::
now
()
-
t_start
).
count
();
return
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
std
::
chrono
::
steady
_clock
::
now
()
-
t_start
).
count
();
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
timeout_t
PassiveTimer
::
getInterval
()
const
noexcept
timeout_t
PassiveTimer
::
getInterval
()
const
noexcept
...
...
src/Timers/WaitingPassiveTimer.cc
View file @
73b6ea42
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