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:
@@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2007, Axel Dörfler, [email protected]. 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;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user