Forgot to add this one in the previous commit: The PageCacheLocker does have

its own source file now that the page daemon source file is gone.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35394 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2010-02-03 18:55:52 +00:00
parent 40bb94819e
commit 9908d834be

View File

@ -0,0 +1,54 @@
/*
* Copyright 2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include "PageCacheLocker.h"
#include <vm/VMCache.h>
bool
PageCacheLocker::_IgnorePage(vm_page* page)
{
if (page->busy || page->state == PAGE_STATE_WIRED
|| page->state == PAGE_STATE_FREE || page->state == PAGE_STATE_CLEAR
|| page->state == PAGE_STATE_UNUSED || page->wired_count > 0)
return true;
return false;
}
bool
PageCacheLocker::Lock(vm_page* page, bool dontWait)
{
if (_IgnorePage(page))
return false;
// Grab a reference to this cache.
VMCache* cache = vm_cache_acquire_locked_page_cache(page, dontWait);
if (cache == NULL)
return false;
if (_IgnorePage(page)) {
cache->ReleaseRefAndUnlock();
return false;
}
fPage = page;
return true;
}
void
PageCacheLocker::Unlock()
{
if (fPage == NULL)
return;
fPage->Cache()->ReleaseRefAndUnlock();
fPage = NULL;
}