My Project
|
00001 #ifndef SYS_VARS_SHARED_INCLUDED 00002 #define SYS_VARS_SHARED_INCLUDED 00003 00004 /* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; version 2 of the License. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program; if not, write to the Free Software Foundation, 00017 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ 00018 00028 #include <sql_priv.h> 00029 #include "set_var.h" 00030 00031 extern bool throw_bounds_warning(THD *thd, const char *name, 00032 bool fixed, bool is_unsigned, longlong v); 00033 extern bool throw_bounds_warning(THD *thd, const char *name, bool fixed, 00034 double v); 00035 extern sys_var *intern_find_sys_var(const char *str, uint length); 00036 00037 extern sys_var_chain all_sys_vars; 00038 00040 class PolyLock 00041 { 00042 public: 00043 virtual void rdlock()= 0; 00044 virtual void wrlock()= 0; 00045 virtual void unlock()= 0; 00046 virtual ~PolyLock() {} 00047 }; 00048 00049 class PolyLock_mutex: public PolyLock 00050 { 00051 mysql_mutex_t *mutex; 00052 public: 00053 PolyLock_mutex(mysql_mutex_t *arg): mutex(arg) {} 00054 void rdlock() { mysql_mutex_lock(mutex); } 00055 void wrlock() { mysql_mutex_lock(mutex); } 00056 void unlock() { mysql_mutex_unlock(mutex); } 00057 }; 00058 00059 class PolyLock_rwlock: public PolyLock 00060 { 00061 mysql_rwlock_t *rwlock; 00062 public: 00063 PolyLock_rwlock(mysql_rwlock_t *arg): rwlock(arg) {} 00064 void rdlock() { mysql_rwlock_rdlock(rwlock); } 00065 void wrlock() { mysql_rwlock_wrlock(rwlock); } 00066 void unlock() { mysql_rwlock_unlock(rwlock); } 00067 }; 00068 00069 class AutoWLock 00070 { 00071 PolyLock *lock; 00072 public: 00073 AutoWLock(PolyLock *l) : lock(l) { if (lock) lock->wrlock(); } 00074 ~AutoWLock() { if (lock) lock->unlock(); } 00075 }; 00076 00077 class AutoRLock 00078 { 00079 PolyLock *lock; 00080 public: 00081 AutoRLock(PolyLock *l) : lock(l) { if (lock) lock->rdlock(); } 00082 ~AutoRLock() { if (lock) lock->unlock(); } 00083 }; 00084 00085 00086 #endif /* SYS_VARS_SHARED_INCLUDED */