Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

atomic.hpp

Go to the documentation of this file.
00001 /*==========================================================================
00002  * Copyright (c) 2004 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 //
00013 // atomic
00014 //
00015 // 15 December 2004 -- tds
00016 //
00017 
00018 #ifndef INDRI_ATOMIC_HPP
00019 #define INDRI_ATOMIC_HPP
00020 
00021 #ifndef WIN32
00022 #if HAVE_BITS_ATOMICITY_H
00023 #include <bits/atomicity.h>
00024 #endif
00025 #if HAVE_EXT_ATOMICITY_H
00026 #include <ext/atomicity.h>
00027 #endif
00028 #endif
00029 
00030 namespace indri {
00032   namespace atomic {
00033 #ifdef WIN32
00034     typedef volatile LONG value_type;
00035 
00036     inline void increment( value_type& variable ) {
00037       ::InterlockedIncrement( &variable );
00038     }
00039 
00040     inline void decrement( value_type& variable ) {
00041       ::InterlockedDecrement( &variable );
00042     }
00043 #else
00044     // GCC 3.4+ declares these in the __gnu_cxx namespace, 3.3- does not.
00045     #if P_NEEDS_GNU_CXX_NAMESPACE
00046     #define __atomic_add __gnu_cxx::__atomic_add
00047     #endif
00048     typedef _Atomic_word value_type;
00049 
00050     inline void increment( value_type& variable ) {
00051      __atomic_add( &variable, 1 );
00052     }
00053 
00054     inline void decrement( value_type& variable ) {
00055       __atomic_add( &variable, -1 );
00056     }
00057 #endif
00058   }
00059 }
00060 
00061 #endif // INDRI_ATOMIC_HPP
00062 

Generated on Tue Jun 15 11:02:53 2010 for Lemur by doxygen 1.3.4