mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 19:33:01 +02:00
some QThread cleanup and fix in Socket
This commit is contained in:
parent
fa0abe2972
commit
de2bfd0d0d
7 changed files with 23 additions and 12 deletions
|
@ -457,8 +457,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
||||||
|
|
||||||
audioThread->start();
|
audioThread->start();
|
||||||
|
|
||||||
|
QThread* assetThread = new QThread;
|
||||||
QThread* assetThread = new QThread();
|
|
||||||
|
|
||||||
assetThread->setObjectName("Asset Thread");
|
assetThread->setObjectName("Asset Thread");
|
||||||
auto assetClient = DependencyManager::get<AssetClient>();
|
auto assetClient = DependencyManager::get<AssetClient>();
|
||||||
|
@ -467,7 +466,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
||||||
|
|
||||||
assetThread->start();
|
assetThread->start();
|
||||||
|
|
||||||
|
|
||||||
const DomainHandler& domainHandler = nodeList->getDomainHandler();
|
const DomainHandler& domainHandler = nodeList->getDomainHandler();
|
||||||
|
|
||||||
connect(&domainHandler, SIGNAL(hostnameChanged(const QString&)), SLOT(domainChanged(const QString&)));
|
connect(&domainHandler, SIGNAL(hostnameChanged(const QString&)), SLOT(domainChanged(const QString&)));
|
||||||
|
@ -879,6 +877,12 @@ Application::~Application() {
|
||||||
DependencyManager::destroy<ScriptCache>();
|
DependencyManager::destroy<ScriptCache>();
|
||||||
DependencyManager::destroy<SoundCache>();
|
DependencyManager::destroy<SoundCache>();
|
||||||
|
|
||||||
|
// cleanup the AssetClient thread
|
||||||
|
QThread* assetThread = DependencyManager::get<AssetClient>()->thread();
|
||||||
|
DependencyManager::destroy<AssetClient>();
|
||||||
|
assetThread->quit();
|
||||||
|
assetThread->wait();
|
||||||
|
|
||||||
QThread* nodeThread = DependencyManager::get<NodeList>()->thread();
|
QThread* nodeThread = DependencyManager::get<NodeList>()->thread();
|
||||||
|
|
||||||
// remove the NodeList from the DependencyManager
|
// remove the NodeList from the DependencyManager
|
||||||
|
|
|
@ -24,6 +24,11 @@ MessageID AssetClient::_currentID = 0;
|
||||||
|
|
||||||
|
|
||||||
AssetClient::AssetClient() {
|
AssetClient::AssetClient() {
|
||||||
|
|
||||||
|
setCustomDeleter([](Dependency* dependency){
|
||||||
|
static_cast<AssetClient*>(dependency)->deleteLater();
|
||||||
|
});
|
||||||
|
|
||||||
auto& packetReceiver = DependencyManager::get<NodeList>()->getPacketReceiver();
|
auto& packetReceiver = DependencyManager::get<NodeList>()->getPacketReceiver();
|
||||||
packetReceiver.registerListener(PacketType::AssetGetInfoReply, this, "handleAssetGetInfoReply");
|
packetReceiver.registerListener(PacketType::AssetGetInfoReply, this, "handleAssetGetInfoReply");
|
||||||
packetReceiver.registerMessageListener(PacketType::AssetGetReply, this, "handleAssetGetReply");
|
packetReceiver.registerMessageListener(PacketType::AssetGetReply, this, "handleAssetGetReply");
|
||||||
|
|
|
@ -53,7 +53,7 @@ std::unique_ptr<SendQueue> SendQueue::create(Socket* socket, HifiSockAddr destin
|
||||||
Q_ASSERT_X(socket, "SendQueue::create", "Must be called with a valid Socket*");
|
Q_ASSERT_X(socket, "SendQueue::create", "Must be called with a valid Socket*");
|
||||||
|
|
||||||
// Setup queue private thread
|
// Setup queue private thread
|
||||||
QThread* thread = new QThread();
|
QThread* thread = new QThread;
|
||||||
thread->setObjectName("Networking: SendQueue " + destination.objectName()); // Name thread for easier debug
|
thread->setObjectName("Networking: SendQueue " + destination.objectName()); // Name thread for easier debug
|
||||||
|
|
||||||
connect(thread, &QThread::started, queue.get(), &SendQueue::run);
|
connect(thread, &QThread::started, queue.get(), &SendQueue::run);
|
||||||
|
|
|
@ -30,10 +30,10 @@ Socket::Socket(QObject* parent) :
|
||||||
connect(&_udpSocket, &QUdpSocket::readyRead, this, &Socket::readPendingDatagrams);
|
connect(&_udpSocket, &QUdpSocket::readyRead, this, &Socket::readPendingDatagrams);
|
||||||
|
|
||||||
// make sure our synchronization method is called every SYN interval
|
// make sure our synchronization method is called every SYN interval
|
||||||
connect(&_synTimer, &QTimer::timeout, this, &Socket::rateControlSync);
|
connect(_synTimer, &QTimer::timeout, this, &Socket::rateControlSync);
|
||||||
|
|
||||||
// start our timer for the synchronization time interval
|
// start our timer for the synchronization time interval
|
||||||
_synTimer.start(_synInterval);
|
_synTimer->start(_synInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Socket::rebind() {
|
void Socket::rebind() {
|
||||||
|
@ -262,10 +262,10 @@ void Socket::rateControlSync() {
|
||||||
connection.second->sync();
|
connection.second->sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_synTimer.interval() != _synInterval) {
|
if (_synTimer->interval() != _synInterval) {
|
||||||
// if the _synTimer interval doesn't match the current _synInterval (changes when the CC factory is changed)
|
// if the _synTimer interval doesn't match the current _synInterval (changes when the CC factory is changed)
|
||||||
// then restart it now with the right interval
|
// then restart it now with the right interval
|
||||||
_synTimer.start(_synInterval);
|
_synTimer->start(_synInterval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@ class Socket : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
Socket(QObject* object = 0);
|
Socket(QObject* object = 0);
|
||||||
|
~Socket();
|
||||||
|
|
||||||
quint16 localPort() const { return _udpSocket.localPort(); }
|
quint16 localPort() const { return _udpSocket.localPort(); }
|
||||||
|
|
||||||
|
@ -97,7 +98,7 @@ private:
|
||||||
QMutex _connectionsMutex; // guards concurrent access to connections hashs
|
QMutex _connectionsMutex; // guards concurrent access to connections hashs
|
||||||
|
|
||||||
int _synInterval = 10; // 10ms
|
int _synInterval = 10; // 10ms
|
||||||
QTimer _synTimer;
|
QTimer* _synTimer;
|
||||||
|
|
||||||
std::unique_ptr<CongestionControlVirtualFactory> _ccFactory { new CongestionControlFactory<DefaultCC>() };
|
std::unique_ptr<CongestionControlVirtualFactory> _ccFactory { new CongestionControlFactory<DefaultCC>() };
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,6 +19,7 @@ GenericThread::GenericThread(QObject* parent) :
|
||||||
_stopThread(false),
|
_stopThread(false),
|
||||||
_isThreaded(false) // assume non-threaded, must call initialize()
|
_isThreaded(false) // assume non-threaded, must call initialize()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GenericThread::~GenericThread() {
|
GenericThread::~GenericThread() {
|
||||||
|
|
Loading…
Reference in a new issue