Cache the retrace semaphore. Use the right kind of locking

in the method that needs it.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39096 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2010-10-23 22:19:43 +00:00
parent 1076d97b5a
commit ed55cb5a22
2 changed files with 15 additions and 12 deletions

View File

@ -138,6 +138,8 @@ AccelerantHWInterface::AccelerantHWInterface()
fInitialModeSwitch(true), fInitialModeSwitch(true),
fRetraceSemaphore(-1),
fRectParams(new (nothrow) fill_rect_params[kDefaultParamsCount]), fRectParams(new (nothrow) fill_rect_params[kDefaultParamsCount]),
fRectParamsCount(kDefaultParamsCount), fRectParamsCount(kDefaultParamsCount),
fBlitParams(new (nothrow) blit_params[kDefaultParamsCount]), fBlitParams(new (nothrow) blit_params[kDefaultParamsCount]),
@ -1017,30 +1019,29 @@ AccelerantHWInterface::GetMonitorInfo(monitor_info* info)
sem_id sem_id
AccelerantHWInterface::RetraceSemaphore() AccelerantHWInterface::RetraceSemaphore()
{ {
AutoWriteLocker _(this);
if (fRetraceSemaphore != -1)
return fRetraceSemaphore;
accelerant_retrace_semaphore AccelerantRetraceSemaphore = accelerant_retrace_semaphore AccelerantRetraceSemaphore =
(accelerant_retrace_semaphore)fAccelerantHook( (accelerant_retrace_semaphore)fAccelerantHook(
B_ACCELERANT_RETRACE_SEMAPHORE, NULL); B_ACCELERANT_RETRACE_SEMAPHORE, NULL);
if (!AccelerantRetraceSemaphore) if (!AccelerantRetraceSemaphore)
return B_UNSUPPORTED; fRetraceSemaphore = B_UNSUPPORTED;
else
fRetraceSemaphore = AccelerantRetraceSemaphore();
return AccelerantRetraceSemaphore(); return fRetraceSemaphore;
} }
status_t status_t
AccelerantHWInterface::WaitForRetrace(bigtime_t timeout) AccelerantHWInterface::WaitForRetrace(bigtime_t timeout)
{ {
AutoReadLocker _(this); sem_id sem = RetraceSemaphore();
accelerant_retrace_semaphore AccelerantRetraceSemaphore
= (accelerant_retrace_semaphore)fAccelerantHook(
B_ACCELERANT_RETRACE_SEMAPHORE, NULL);
if (!AccelerantRetraceSemaphore)
return B_UNSUPPORTED;
sem_id sem = AccelerantRetraceSemaphore();
if (sem < 0) if (sem < 0)
return B_ERROR; return sem;
return acquire_sem_etc(sem, 1, B_RELATIVE_TIMEOUT, timeout); return acquire_sem_etc(sem, 1, B_RELATIVE_TIMEOUT, timeout);
} }

View File

@ -177,6 +177,8 @@ private:
display_mode fDisplayMode; display_mode fDisplayMode;
bool fInitialModeSwitch; bool fInitialModeSwitch;
sem_id fRetraceSemaphore;
mutable fill_rect_params* fRectParams; mutable fill_rect_params* fRectParams;
mutable uint32 fRectParamsCount; mutable uint32 fRectParamsCount;
mutable blit_params* fBlitParams; mutable blit_params* fBlitParams;