LinuxRecursivePosixMutexSpecialization.hh

00001 //********************************************************************
00002 //*** Thread/LinuxRecursivePosixMutexSpecialization.hh
00003 //*** Copyright (c) 2003-2009 by Markus Winand <mws@fatalmind.com>
00004 //*** $Id: LinuxRecursivePosixMutexSpecialization.hh,v 1.8 2009-03-02 14:16:46 mws Exp $
00005 //********************************************************************
00006 
00007 #ifndef INCLUDED_LINUXRECURSIVEPOSIXMUTEXSPECIALIZATION_H
00008 #define INCLUDED_LINUXRECURSIVEPOSIXMUTEXSPECIALIZATION_H
00009 
00010 #ifdef HAVE_CONFIG_H
00011 #include "../config.h"
00012 #endif
00013 
00014 #ifdef HAVE_PTHREAD_MUTEXATTR_SETTYPE
00015 #ifdef HAVE_PTHREAD_MUTEX_RECURSIVE_NP
00016 
00017 #ifndef INCLUDED_ERRNO_H
00018 #include "../Exceptions/Errno.hh"
00019 #endif
00020 
00021 #include <pthread.h>
00022 
00023 namespace fatalmind {
00024 
00025 class LinuxRecursivePosixMutexSpecialization {
00026     public:
00027         inline void recursive_ok() {
00028         }
00029 
00030     protected:
00031         LinuxRecursivePosixMutexSpecialization() {
00032             Errno::ThrowOnError(
00033                 pthread_mutexattr_init(&d_mutexattr)
00034             );
00035             Errno::ThrowOnError(
00036                 pthread_mutexattr_settype(&d_mutexattr
00037                     , PTHREAD_MUTEX_RECURSIVE_NP
00038                 )
00039             );
00040         }
00041 
00042         inline pthread_mutexattr_t* getAttr() {
00043             return &d_mutexattr;
00044         }
00045 
00046         ~LinuxRecursivePosixMutexSpecialization() {
00047             pthread_mutexattr_destroy(&d_mutexattr);
00048         }
00049     protected:
00050          pthread_mutexattr_t d_mutexattr;
00051 };
00052 
00053 } // namespace fatalmind
00054 
00055 #endif // HAVE_HAVE_PTHREAD_MUTEX_RECURSIVE_NP
00056 #endif // HAVE_PTHREAD_MUTEXATTR_SETTYPE
00057 
00058 #endif

Generated on Mon Nov 9 16:21:24 2009 for ResourcePool by  doxygen 1.5.3