mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 01:24:03 +02:00
Merge pull request #2557 from ZappoMan/bugfixes
tweaks to _processLock to reduce time it's locked
This commit is contained in:
commit
069008c03f
1 changed files with 14 additions and 6 deletions
|
@ -48,26 +48,28 @@ OctreeSendThread::~OctreeSendThread() {
|
|||
}
|
||||
|
||||
void OctreeSendThread::setIsShuttingDown() {
|
||||
QMutexLocker locker(&_processLock); // this will cause us to wait till the process loop is complete
|
||||
_isShuttingDown = true;
|
||||
OctreeServer::stopTrackingThread(this);
|
||||
|
||||
// this will cause us to wait till the process loop is complete, we do this after we change _isShuttingDown
|
||||
QMutexLocker locker(&_processLock);
|
||||
}
|
||||
|
||||
|
||||
bool OctreeSendThread::process() {
|
||||
if (_isShuttingDown) {
|
||||
return false; // exit early if we're shutting down
|
||||
}
|
||||
|
||||
OctreeServer::didProcess(this);
|
||||
|
||||
float lockWaitElapsedUsec = OctreeServer::SKIP_TIME;
|
||||
quint64 lockWaitStart = usecTimestampNow();
|
||||
QMutexLocker locker(&_processLock);
|
||||
_processLock.lock();
|
||||
quint64 lockWaitEnd = usecTimestampNow();
|
||||
lockWaitElapsedUsec = (float)(lockWaitEnd - lockWaitStart);
|
||||
OctreeServer::trackProcessWaitTime(lockWaitElapsedUsec);
|
||||
|
||||
if (_isShuttingDown) {
|
||||
return false; // exit early if we're shutting down
|
||||
}
|
||||
|
||||
quint64 start = usecTimestampNow();
|
||||
|
||||
// don't do any send processing until the initial load of the octree is complete...
|
||||
|
@ -98,6 +100,12 @@ bool OctreeSendThread::process() {
|
|||
}
|
||||
}
|
||||
|
||||
_processLock.unlock();
|
||||
|
||||
if (_isShuttingDown) {
|
||||
return false; // exit early if we're shutting down
|
||||
}
|
||||
|
||||
// Only sleep if we're still running and we got the lock last time we tried, otherwise try to get the lock asap
|
||||
if (isStillRunning()) {
|
||||
// dynamically sleep until we need to fire off the next set of octree elements
|
||||
|
|
Loading…
Reference in a new issue