00001 #ifndef __threading_mutex_h__ 00002 #define __threading_mutex_h__ 00003 00004 #include "application_config.h" 00005 00006 #if NO_THREAD_SAFETY 00007 00008 #define mutex_init(m) 00009 #define mutex_lock(m) 00010 #define mutex_unlock(m) 00011 #define mutex_destroy(m) 00012 00013 #else // NO_THREAD_SAFETY 00014 00015 // Note that if NDEBUG is defined at the time when <assert.h> is 00016 // included, then "assert" generates no code. Otherwise it does, and 00017 // we rely on that here. 00018 // 00019 // Mutex use should never produce an error unless there is a coding 00020 // error of some sort. 00021 00022 #ifdef NDEBUG 00023 #define mutex_assert_no_err(expr) expr 00024 #else 00025 #include "common/assertions.h" 00026 #define mutex_assert_no_err(expr) assert((expr) == 0) 00027 #endif // NDEBUG 00028 00029 #include <pthread.h> 00030 00031 #define mutex_init(m) mutex_assert_no_err(pthread_mutex_init(m, NULL)) 00032 #define mutex_lock(m) mutex_assert_no_err(pthread_mutex_lock(m)) 00033 #define mutex_unlock(m) mutex_assert_no_err(pthread_mutex_unlock(m)) 00034 #define mutex_destroy(m) mutex_assert_no_err(pthread_mutex_destroy(m)) 00035 00036 #endif // NO_THREAD_SAFETY 00037 00038 #define mutex_synchronized(m,stmt) { \ 00039 mutex_lock(m); \ 00040 stmt; \ 00041 mutex_unlock(m); \ 00042 } 00043 00044 #endif /* __threading_mutex_h__ */ 00045 00046 /** 00047 00048 threading_mutex.h 00049 00050 Copyright 2009 Helsinki Institute for Information Technology (HIIT) 00051 and the authors. All rights reserved. 00052 00053 Authors: Tero Hasu <tero.hasu@hut.fi> 00054 00055 Permission is hereby granted, free of charge, to any person 00056 obtaining a copy of this software and associated documentation files 00057 (the "Software"), to deal in the Software without restriction, 00058 including without limitation the rights to use, copy, modify, merge, 00059 publish, distribute, sublicense, and/or sell copies of the Software, 00060 and to permit persons to whom the Software is furnished to do so, 00061 subject to the following conditions: 00062 00063 The above copyright notice and this permission notice shall be 00064 included in all copies or substantial portions of the Software. 00065 00066 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00067 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00068 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00069 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 00070 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 00071 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 00072 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 00073 SOFTWARE. 00074 00075 **/
ContextLogger2—ContextLogger2 Logger Daemon Internals—Generated on Mon May 2 13:49:56 2011 by Doxygen 1.6.1