Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages  

sglLock.hpp

00001 /*****************************************************************************
00002  * SGL: A Scene Graph Library
00003  *
00004  * Copyright (C) 1997-2001  Scott McMillan   All Rights Reserved.
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Library General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Library General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Library General Public
00017  * License along with this library; if not, write to the Free
00018  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  *****************************************************************************
00020  *     File: sglLock.hpp
00021  *   Author: Tom Stimson
00022  *  Created: 22 October 2000
00023  *  Summary: Binary semaphore.
00024  *****************************************************************************/
00025 
00026 /*
00027  * Copyright (c) 1997-1999
00028  * Silicon Graphics Computer Systems, Inc.
00029  *
00030  * Permission to use, copy, modify, distribute and sell this software
00031  * and its documentation for any purpose is hereby granted without fee,
00032  * provided that the above copyright notice appear in all copies and
00033  * that both that copyright notice and this permission notice appear
00034  * in supporting documentation.  Silicon Graphics makes no
00035  * representations about the suitability of this software for any
00036  * purpose.  It is provided "as is" without express or implied warranty.
00037  */
00038 
00039 
00040 #ifndef __SGL_LOCK_HPP
00041 #define __SGL_LOCK_HPP
00042 
00043 #include <sgl.h>
00044 
00045 #if defined(sgi)
00046 # include <mutex.h>
00047 # include <time.h>
00048 #elif defined(vxw)
00049 # include <semLib.h>
00050 #elif defined(WIN32)
00051 //do nothing
00052 #else // assume posix
00053 # include <pthread.h>
00054 #endif
00055 
00056 //----------------------------------------------------------------------------
00057 
00063 class SGL_DLL_API sglLock
00064 {
00065 public:
00067    sglLock();
00069    ~sglLock();
00070 
00072    void acquire();
00073 
00075    void release();
00076 
00077 private:
00078    // not implemented
00079    sglLock(const sglLock &);
00080    sglLock &operator=(const sglLock &);
00081 
00082 private:
00083 #if defined(WIN32) || defined(sgi)
00084    volatile unsigned long m_lock;
00085    unsigned long m_last;
00086    unsigned long m_max;
00087    static unsigned long s_low_max;
00088    static unsigned long s_high_max;
00089 #elif defined(vxw)
00090    SEM_ID m_lock;
00091 #else // assume posix
00092    pthread_mutex_t m_lock;
00093 #endif
00094 };
00095 
00096 #endif

Generated at Mon Jul 1 18:00:05 2002 for SGL by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001