1/* 2 * Copyright 2007, Axel D��rfler, axeld@pinc-software.de. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5#ifndef PAGE_CACHE_LOCKER_H 6#define PAGE_CACHE_LOCKER_H 7 8 9#include <null.h> 10 11struct vm_page; 12 13 14class PageCacheLocker { 15public: 16 inline PageCacheLocker(vm_page* page, 17 bool dontWait = true); 18 inline ~PageCacheLocker(); 19 20 bool IsLocked() { return fPage != NULL; } 21 22 bool Lock(vm_page* page, bool dontWait = true); 23 void Unlock(); 24 25private: 26 bool _IgnorePage(vm_page* page); 27 28 vm_page* fPage; 29}; 30 31 32PageCacheLocker::PageCacheLocker(vm_page* page, bool dontWait) 33 : 34 fPage(NULL) 35{ 36 Lock(page, dontWait); 37} 38 39 40PageCacheLocker::~PageCacheLocker() 41{ 42 Unlock(); 43} 44 45 46#endif // PAGE_CACHE_LOCKER_H 47