mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 14:47:41 +02:00
thread safe timing of domain connection
This commit is contained in:
parent
08affbfd0d
commit
9cb6ccaa46
3 changed files with 14 additions and 5 deletions
|
@ -69,11 +69,12 @@ DomainConnectionDialog::DomainConnectionDialog(QWidget* parent) :
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// setup a horizontal box layout
|
||||||
QHBoxLayout* hBoxLayout = new QHBoxLayout;
|
QHBoxLayout* hBoxLayout = new QHBoxLayout;
|
||||||
hBoxLayout->addWidget(timeTable);
|
hBoxLayout->addWidget(timeTable);
|
||||||
hBoxLayout->setSizeConstraint(QLayout::SetMinimumSize);
|
hBoxLayout->setSizeConstraint(QLayout::SetMinimumSize);
|
||||||
|
|
||||||
timeTable->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
// resize the table columns
|
||||||
timeTable->resizeColumnsToContents();
|
timeTable->resizeColumnsToContents();
|
||||||
|
|
||||||
// figure out the size of the table so we can size the dialog
|
// figure out the size of the table so we can size the dialog
|
||||||
|
@ -87,6 +88,7 @@ DomainConnectionDialog::DomainConnectionDialog(QWidget* parent) :
|
||||||
tableHeight += timeTable->rowHeight(i);
|
tableHeight += timeTable->rowHeight(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set the minimum size of the table to whatever we got
|
||||||
timeTable->setMinimumSize(tableWidth, tableHeight);
|
timeTable->setMinimumSize(tableWidth, tableHeight);
|
||||||
|
|
||||||
setLayout(hBoxLayout);
|
setLayout(hBoxLayout);
|
||||||
|
|
|
@ -270,9 +270,6 @@ void NodeList::reset() {
|
||||||
if (_dtlsSocket) {
|
if (_dtlsSocket) {
|
||||||
disconnect(_dtlsSocket, 0, this, 0);
|
disconnect(_dtlsSocket, 0, this, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset the connection times
|
|
||||||
_lastConnectionTimes.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeList::addNodeTypeToInterestSet(NodeType_t nodeTypeToAdd) {
|
void NodeList::addNodeTypeToInterestSet(NodeType_t nodeTypeToAdd) {
|
||||||
|
@ -673,6 +670,13 @@ void NodeList::flagTimeForConnectionStep(NodeList::ConnectionStep connectionStep
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeList::flagTimeForConnectionStep(NodeList::ConnectionStep connectionStep, quint64 timestamp) {
|
void NodeList::flagTimeForConnectionStep(NodeList::ConnectionStep connectionStep, quint64 timestamp) {
|
||||||
|
QWriteLocker writeLock(&_connectionTimeLock);
|
||||||
|
|
||||||
|
if (connectionStep == NodeList::ConnectionStep::LookupAddress) {
|
||||||
|
// we clear the current times if the user just fired off a lookup
|
||||||
|
_lastConnectionTimes.clear();
|
||||||
|
}
|
||||||
|
|
||||||
// we only add a timestamp on the first call for each NodeList::ConnectionStep
|
// we only add a timestamp on the first call for each NodeList::ConnectionStep
|
||||||
if (!_lastConnectionTimes.contains(connectionStep)) {
|
if (!_lastConnectionTimes.contains(connectionStep)) {
|
||||||
_lastConnectionTimes[connectionStep] = timestamp;
|
_lastConnectionTimes[connectionStep] = timestamp;
|
||||||
|
|
|
@ -84,8 +84,10 @@ public:
|
||||||
|
|
||||||
int processDomainServerList(const QByteArray& packet);
|
int processDomainServerList(const QByteArray& packet);
|
||||||
|
|
||||||
const QMap<ConnectionStep, quint64> getLastConnectionTimes() const { return _lastConnectionTimes; }
|
const QMap<ConnectionStep, quint64> getLastConnectionTimes() const
|
||||||
|
{ QReadLocker readLock(&_connectionTimeLock); return _lastConnectionTimes; }
|
||||||
void flagTimeForConnectionStep(NodeList::ConnectionStep connectionStep);
|
void flagTimeForConnectionStep(NodeList::ConnectionStep connectionStep);
|
||||||
|
void resetConnectionTimes() { QWriteLocker writeLock(&_connectionTimeLock); _lastConnectionTimes.clear(); }
|
||||||
|
|
||||||
void setAssignmentServerSocket(const HifiSockAddr& serverSocket) { _assignmentServerSocket = serverSocket; }
|
void setAssignmentServerSocket(const HifiSockAddr& serverSocket) { _assignmentServerSocket = serverSocket; }
|
||||||
void sendAssignment(Assignment& assignment);
|
void sendAssignment(Assignment& assignment);
|
||||||
|
@ -128,6 +130,7 @@ private:
|
||||||
bool _hasCompletedInitialSTUNFailure;
|
bool _hasCompletedInitialSTUNFailure;
|
||||||
unsigned int _stunRequestsSinceSuccess;
|
unsigned int _stunRequestsSinceSuccess;
|
||||||
|
|
||||||
|
mutable QReadWriteLock _connectionTimeLock { };
|
||||||
QMap<ConnectionStep, quint64> _lastConnectionTimes;
|
QMap<ConnectionStep, quint64> _lastConnectionTimes;
|
||||||
|
|
||||||
friend class Application;
|
friend class Application;
|
||||||
|
|
Loading…
Reference in a new issue