Cocoa Port:

- Fix thread-safety issue when changing the execution speed.
This commit is contained in:
rogerman 2012-07-04 05:17:48 +00:00
parent 5cda370b9d
commit 4f2b3feee4
1 changed files with 2 additions and 2 deletions

View File

@ -589,7 +589,7 @@ static BOOL isCoreStarted = NO;
theSpeed = SPEED_SCALAR_MIN;
}
pthread_mutex_unlock(&threadParam.mutexThreadExecute);
pthread_mutex_lock(&threadParam.mutexThreadExecute);
uint64_t timeBudgetNanoseconds = (uint64_t)(DS_SECONDS_PER_FRAME * 1000000000.0 / theSpeed);
AbsoluteTime timeBudgetAbsTime = NanosecondsToAbsolute(*(Nanoseconds *)&timeBudgetNanoseconds);
threadParam.timeBudgetMachAbsTime = *(uint64_t *)&timeBudgetAbsTime;
@ -597,7 +597,7 @@ static BOOL isCoreStarted = NO;
}
else
{
pthread_mutex_unlock(&threadParam.mutexThreadExecute);
pthread_mutex_lock(&threadParam.mutexThreadExecute);
threadParam.timeBudgetMachAbsTime = 0;
pthread_mutex_unlock(&threadParam.mutexThreadExecute);
}