put Agent AssetClient on sep thread, cleanup

This commit is contained in:
Stephen Birarda 2015-10-26 12:06:25 -07:00
parent d941be8d0b
commit 5908f2d398

View file

@ -44,7 +44,14 @@ Agent::Agent(NLPacket& packet) :
{ {
DependencyManager::get<EntityScriptingInterface>()->setPacketSender(&_entityEditSender); DependencyManager::get<EntityScriptingInterface>()->setPacketSender(&_entityEditSender);
DependencyManager::set<AssetClient>(); auto assetClient = DependencyManager::set<AssetClient>();
QThread* assetThread = new QThread;
assetThread->setObjectName("Asset Thread");
assetClient->moveToThread(assetThread);
connect(assetThread, &QThread::started, assetClient.data(), &AssetClient::init);
assetThread->start();
DependencyManager::set<ResourceCacheSharedItems>(); DependencyManager::set<ResourceCacheSharedItems>();
DependencyManager::set<SoundCache>(); DependencyManager::set<SoundCache>();
@ -371,6 +378,7 @@ void Agent::processAgentAvatarAndAudio(float deltaTime) {
void Agent::aboutToFinish() { void Agent::aboutToFinish() {
setIsAvatar(false);// will stop timers for sending billboards and identity packets setIsAvatar(false);// will stop timers for sending billboards and identity packets
if (_scriptEngine) { if (_scriptEngine) {
_scriptEngine->stop(); _scriptEngine->stop();
} }
@ -382,6 +390,12 @@ void Agent::aboutToFinish() {
// our entity tree is going to go away so tell that to the EntityScriptingInterface // our entity tree is going to go away so tell that to the EntityScriptingInterface
DependencyManager::get<EntityScriptingInterface>()->setEntityTree(NULL); DependencyManager::get<EntityScriptingInterface>()->setEntityTree(NULL);
// cleanup the AssetClient thread
QThread* assetThread = DependencyManager::get<AssetClient>()->thread();
DependencyManager::destroy<AssetClient>();
assetThread->quit();
assetThread->wait();
} }
void Agent::sendPingRequests() { void Agent::sendPingRequests() {