Inlined several VMCache methods.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34837 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2010-01-01 17:09:23 +00:00
parent 1021fd2826
commit 355dc6bef4
2 changed files with 83 additions and 54 deletions
+83 -15
View File
@@ -10,6 +10,7 @@
#define _KERNEL_VM_VM_CACHE_H #define _KERNEL_VM_VM_CACHE_H
#include <debug.h>
#include <kernel.h> #include <kernel.h>
#include <vm/vm.h> #include <vm/vm.h>
#include <vm/vm_types.h> #include <vm/vm_types.h>
@@ -69,23 +70,17 @@ public:
virtual void Delete(); virtual void Delete();
bool Lock() inline bool Lock();
{ return mutex_lock(&fLock) == B_OK; } inline bool TryLock();
bool TryLock() inline bool SwitchLock(mutex* from);
{ return mutex_trylock(&fLock) == B_OK; }
bool SwitchLock(mutex* from)
{ return mutex_switch_lock(from, &fLock)
== B_OK; }
void Unlock(); void Unlock();
void AssertLocked() inline void AssertLocked();
{ ASSERT_LOCKED_MUTEX(&fLock); }
void AcquireRefLocked(); inline void AcquireRefLocked();
void AcquireRef(); inline void AcquireRef();
void ReleaseRefLocked(); inline void ReleaseRefLocked();
void ReleaseRef(); inline void ReleaseRef();
void ReleaseRefAndUnlock() inline void ReleaseRefAndUnlock();
{ ReleaseRefLocked(); Unlock(); }
void WaitForPageEvents(vm_page* page, uint32 events, void WaitForPageEvents(vm_page* page, uint32 events,
bool relock); bool relock);
@@ -203,6 +198,79 @@ public:
}; };
bool
VMCache::Lock()
{
return mutex_lock(&fLock) == B_OK;
}
bool
VMCache::TryLock()
{
return mutex_trylock(&fLock) == B_OK;
}
bool
VMCache::SwitchLock(mutex* from)
{
return mutex_switch_lock(from, &fLock) == B_OK;
}
void
VMCache::AssertLocked()
{
ASSERT_LOCKED_MUTEX(&fLock);
}
void
VMCache::AcquireRefLocked()
{
ASSERT_LOCKED_MUTEX(&fLock);
fRefCount++;
}
void
VMCache::AcquireRef()
{
Lock();
fRefCount++;
Unlock();
}
void
VMCache::ReleaseRefLocked()
{
ASSERT_LOCKED_MUTEX(&fLock);
fRefCount--;
}
void
VMCache::ReleaseRef()
{
Lock();
fRefCount--;
Unlock();
}
void
VMCache::ReleaseRefAndUnlock()
{
ReleaseRefLocked();
Unlock();
}
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
-39
View File
@@ -17,7 +17,6 @@
#include <arch/cpu.h> #include <arch/cpu.h>
#include <condition_variable.h> #include <condition_variable.h>
#include <debug.h>
#include <heap.h> #include <heap.h>
#include <int.h> #include <int.h>
#include <kernel.h> #include <kernel.h>
@@ -679,44 +678,6 @@ VMCache::Unlock()
} }
void
VMCache::AcquireRefLocked()
{
// TODO: Inline!
ASSERT_LOCKED_MUTEX(&fLock);
fRefCount++;
}
void
VMCache::AcquireRef()
{
Lock();
fRefCount++;
Unlock();
}
void
VMCache::ReleaseRefLocked()
{
// TODO: Inline!
ASSERT_LOCKED_MUTEX(&fLock);
fRefCount--;
}
void
VMCache::ReleaseRef()
{
Lock();
fRefCount--;
Unlock();
}
vm_page* vm_page*
VMCache::LookupPage(off_t offset) VMCache::LookupPage(off_t offset)
{ {