spin_lock_darwin.h

Go to the documentation of this file.
00001 
00003 
00004 //
00005 // Copyright (c) 2007-2007 University of Southern California
00006 // Rob Peters <rjpeters at usc dot edu>
00007 //
00008 // created: Tue Sep  4 14:08:02 2007
00009 // commit: $Id: spin_lock_darwin.h 10134 2008-03-04 17:58:05Z rjpeters $
00010 // $HeadURL: file:///lab/rjpeters/svnrepo/code/trunk/groovx/src/rutz/spin_lock_darwin.h $
00011 //
00012 // --------------------------------------------------------------------
00013 //
00014 // This file is part of GroovX.
00015 //   [http://www.klab.caltech.edu/rjpeters/groovx/]
00016 //
00017 // GroovX is free software; you can redistribute it and/or modify it
00018 // under the terms of the GNU General Public License as published by
00019 // the Free Software Foundation; either version 2 of the License, or
00020 // (at your option) any later version.
00021 //
00022 // GroovX is distributed in the hope that it will be useful, but
00023 // WITHOUT ANY WARRANTY; without even the implied warranty of
00024 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00025 // General Public License for more details.
00026 //
00027 // You should have received a copy of the GNU General Public License
00028 // along with GroovX; if not, write to the Free Software Foundation,
00029 // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
00030 //
00032 
00033 #ifndef GROOVX_RUTZ_SPIN_LOCK_DARWIN_H_UTC20070904210802_DEFINED
00034 #define GROOVX_RUTZ_SPIN_LOCK_DARWIN_H_UTC20070904210802_DEFINED
00035 
00036 #include <libkern/OSAtomic.h>
00037 
00038 namespace rutz
00039 {
00040 
00041 class spin_lock_darwin
00042 {
00043 private:
00044   OSSpinLock m_lock;
00045 
00046   spin_lock_darwin(const spin_lock_darwin&); // not implemented
00047   spin_lock_darwin& operator=(const spin_lock_darwin&); // not implemented
00048 
00049 public:
00050   spin_lock_darwin()
00051   { OSSpinLockUnlock(&m_lock); }
00052 
00053   void lock()
00054   { OSSpinLockLock(&m_lock); }
00055 
00056   bool try_lock()
00057   { return OSSpinLockTry(&m_lock); }
00058 
00059   void unlock()
00060   { OSSpinLockUnlock(&m_lock); }
00061 };
00062 
00063 }
00064 
00065 static const char vcid_groovx_rutz_spin_lock_darwin_h_utc20070904210802[] = "$Id: spin_lock_darwin.h 10134 2008-03-04 17:58:05Z rjpeters $ $HeadURL: file:///lab/rjpeters/svnrepo/code/trunk/groovx/src/rutz/spin_lock_darwin.h $";
00066 #endif // !GROOVX_RUTZ_SPIN_LOCK_DARWIN_H_UTC20070904210802DEFINED

The software described here is Copyright (c) 1998-2005, Rob Peters.
This page was generated Wed Dec 3 06:49:41 2008 by Doxygen version 1.5.5.