00001 /*========================================================================== 00002 * Copyright (c) 2005 University of Massachusetts. All Rights Reserved. 00003 * 00004 * Use of the Lemur Toolkit for Language Modeling and Information Retrieval 00005 * is subject to the terms of the software license set forth in the LICENSE 00006 * file included with this software, and also available at 00007 * http://www.lemurproject.org/license.html 00008 * 00009 *========================================================================== 00010 */ 00011 // 00012 // ReaderLockable 00013 // 00014 // 31 January 2005 -- tds 00015 // 00016 // Lockable adaptor for ReadersWritersLocks 00017 // 00018 00019 #ifndef INDRI_READERLOCKABLE_HPP 00020 #define INDRI_READERLOCKABLE_HPP 00021 00022 #include "indri/ReadersWritersLock.hpp" 00023 #include "indri/Thread.hpp" 00024 namespace indri 00025 { 00026 namespace thread 00027 { 00028 00029 class ReaderLockable : public Lockable { 00030 private: 00031 ReadersWritersLock& _lock; 00032 00033 public: 00034 ReaderLockable( ReadersWritersLock& lock ) : 00035 _lock( lock ) 00036 { 00037 } 00038 00039 void lock() { 00040 _lock.lockRead(); 00041 } 00042 00043 void unlock() { 00044 _lock.unlockRead(); 00045 } 00046 }; 00047 } 00048 } 00049 00050 #endif // INDRI_READERLOCKABLE_HPP 00051