rlog: Lock.h Source File

Main Page | Modules | Class List | Directories | File List | Class Members | Related Pages

# rlog/Lock.h

    00001 /*****************************************************************************
    00002  * Author:   Valient Gough <vgough@pobox.com>
    00003  *
    00004  *****************************************************************************
    00005  * Copyright (c) 2004, Valient Gough
    00006  *
    00007  * This library is free software; you can distribute it and/or modify it under
    00008  * the terms of the GNU Lesser General Public License (LGPL), as published by
    00009  * the Free Software Foundation; either version 2.1 of the License, or (at your
    00010  * option) any later version.
    00011  *
    00012  * This library is distributed in the hope that it will be useful, but WITHOUT
    00013  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    00014  * FITNESS FOR A PARTICULAR PURPOSE.  See the LGPL in the file COPYING for more
    00015  * details.
    00016  *
    00017  */
    00018
    00019
    00020 #ifndef _Lock_incl_
    00021 #define _Lock_incl_
    00022
    00023 #include <rlog/Mutex.h>
    00024
    00025 namespace rlog
    00026 {
    00045     class RLOG_DECL Lock
    00046     {
    00047     public:
    00048         Lock( Mutex * mutex )
    00049             : _mutex( mutex )
    00050         {
    00051             _mutex->Lock();
    00052         }
    00053
    00054         ~Lock()
    00055         {
    00056             _mutex->Unlock();
    00057             _mutex = 0;
    00058         }
    00059
    00060         Mutex *_mutex;
    00061     };
    00062
    00063 } // namespace rlog
    00064
    00065 #endif
    00066