[haiku-commits] r35394 - haiku/trunk/src/system/kernel/vm

  • From: ingo_weinhold@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 3 Feb 2010 19:55:52 +0100 (CET)

Author: bonefish
Date: 2010-02-03 19:55:52 +0100 (Wed, 03 Feb 2010)
New Revision: 35394
Changeset: http://dev.haiku-os.org/changeset/35394/haiku

Added:
   haiku/trunk/src/system/kernel/vm/PageCacheLocker.cpp
Log:
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.


Added: haiku/trunk/src/system/kernel/vm/PageCacheLocker.cpp
===================================================================
--- haiku/trunk/src/system/kernel/vm/PageCacheLocker.cpp                        
        (rev 0)
+++ haiku/trunk/src/system/kernel/vm/PageCacheLocker.cpp        2010-02-03 
18:55:52 UTC (rev 35394)
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2007, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx 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;
+}


Other related posts:

  • » [haiku-commits] r35394 - haiku/trunk/src/system/kernel/vm - ingo_weinhold