version 4.0.0_alpha
in almost all methods removed timeouts in milliseconds, replaced to PISystemTime PITimer rewrite, remove internal impl, now only thread implementation, API similar to PIThread PITimer API no longer pass void* PIPeer, PIConnection improved stability on reinit and exit PISystemTime new methods pisd now exit without hanging
This commit is contained in:
@@ -19,6 +19,8 @@
|
||||
|
||||
#include "pidiagnostics.h"
|
||||
|
||||
#include "piliterals_time.h"
|
||||
|
||||
|
||||
/** \class PIDiagnostics
|
||||
* \brief Connection quality diagnostics
|
||||
@@ -42,18 +44,18 @@ PIDiagnostics::State::State() {
|
||||
}
|
||||
|
||||
|
||||
PIDiagnostics::PIDiagnostics(bool start_): PITimer(/*PITimer::Pool*/) {
|
||||
PIDiagnostics::PIDiagnostics(bool start_): PITimer() {
|
||||
// piCout << "PIDiagnostics construct";
|
||||
setInterval(100);
|
||||
setInterval(10_Hz);
|
||||
reset();
|
||||
setDisconnectTimeout(3.);
|
||||
changeDisconnectTimeout(3.);
|
||||
if (start_) PITimer::start(100);
|
||||
setDisconnectTimeout(3_s);
|
||||
changeDisconnectTimeout(3_s);
|
||||
if (start_) PITimer::start(10_Hz);
|
||||
// piCout << "PIDiagnostics construct done";
|
||||
}
|
||||
|
||||
PIDiagnostics::~PIDiagnostics() {
|
||||
PITimer::stop();
|
||||
PITimer::stopAndWait();
|
||||
// piCout << "~PIDiagnostics start...";
|
||||
// piCout << "~PIDiagnostics done!";
|
||||
}
|
||||
@@ -92,14 +94,14 @@ PIString PIDiagnostics::sendSpeed() const {
|
||||
|
||||
|
||||
void PIDiagnostics::start() {
|
||||
PITimer::start(100.);
|
||||
PITimer::start(10_Hz);
|
||||
changeDisconnectTimeout(disconn_);
|
||||
}
|
||||
|
||||
|
||||
void PIDiagnostics::start(double msecs) {
|
||||
if (msecs > 0.) {
|
||||
PITimer::start(msecs);
|
||||
PITimer::start(PISystemTime::fromMilliseconds(msecs));
|
||||
changeDisconnectTimeout(disconn_);
|
||||
}
|
||||
}
|
||||
@@ -108,7 +110,7 @@ void PIDiagnostics::start(double msecs) {
|
||||
void PIDiagnostics::reset() {
|
||||
mutex_state.lock();
|
||||
cur_state = State();
|
||||
if (disconn_ != 0.) {
|
||||
if (disconn_.isNotNull()) {
|
||||
int hist_size = history_rec.size();
|
||||
history_rec.clear();
|
||||
history_send.clear();
|
||||
@@ -150,16 +152,16 @@ void PIDiagnostics::sended(int size) {
|
||||
}
|
||||
|
||||
|
||||
void PIDiagnostics::tick(void *, int) {
|
||||
void PIDiagnostics::tick(int) {
|
||||
mutex_state.lock();
|
||||
// piCoutObj << "lock";
|
||||
int tcnt_recv = 0;
|
||||
int tcnt_send = 0;
|
||||
Entry send = calcHistory(history_send, tcnt_send);
|
||||
Entry recv = calcHistory(history_rec, tcnt_recv);
|
||||
float itr = disconn_ * (float(tcnt_recv) / history_rec.size());
|
||||
float its = disconn_ * (float(tcnt_send) / history_send.size());
|
||||
float hz = interval() / 1000.f;
|
||||
float itr = disconn_.toSeconds() * (float(tcnt_recv) / history_rec.size());
|
||||
float its = disconn_.toSeconds() * (float(tcnt_send) / history_send.size());
|
||||
float hz = 1. / interval().toSeconds();
|
||||
if (tcnt_recv == 0) {
|
||||
cur_state.integral_freq = cur_state.immediate_freq = 0;
|
||||
cur_state.received_packets_per_sec = cur_state.received_bytes_per_sec = 0;
|
||||
@@ -229,16 +231,15 @@ PIDiagnostics::Entry PIDiagnostics::calcHistory(PIQueue<Entry> & hist, int & cnt
|
||||
|
||||
|
||||
void PIDiagnostics::propertyChanged(const char *) {
|
||||
float disct = property("disconnectTimeout").toFloat();
|
||||
changeDisconnectTimeout(disct);
|
||||
changeDisconnectTimeout(property("disconnectTimeout").toSystemTime());
|
||||
}
|
||||
|
||||
|
||||
void PIDiagnostics::changeDisconnectTimeout(float disct) {
|
||||
void PIDiagnostics::changeDisconnectTimeout(PISystemTime disct) {
|
||||
mutex_state.lock();
|
||||
disconn_ = piMaxf(disct, interval() / 1000.f);
|
||||
if (interval() > 0) {
|
||||
int hist_size = piClampi(int(disconn_ * 1000.f / float(interval())), 1, 65536);
|
||||
disconn_ = piMax(disct, interval());
|
||||
if (!interval().isNull()) {
|
||||
int hist_size = piClampi(piRound(disconn_.toSeconds() / interval().toSeconds()), 1, 65536);
|
||||
// piCoutObj << hist_size << interval();
|
||||
history_rec.resize(hist_size);
|
||||
history_send.resize(hist_size);
|
||||
|
||||
Reference in New Issue
Block a user