1
/* Copyright (c) 2009 PrimeBase Technologies GmbH
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
* 2009-01-20 Vladimir Kolesnikov
24
#ifndef __xt_locklist_h__
25
#define __xt_locklist_h__
28
* XT_THREAD_LOCK_INFO and DEBUG_LOCKING code must be updated to avoid calls to xt_get_self() as it can be called before hton->slot is
29
* assigned by MySQL which is used by xt_get_self()
33
//#define XT_THREAD_LOCK_INFO
35
/* We need DEBUG_LOCKING in order to enable pthread function wrappers */
36
//#define DEBUG_LOCKING
44
struct xt_mutex_struct;
45
struct xt_rwlock_struct;
49
#ifdef XT_THREAD_LOCK_INFO
51
#define XT_THREAD_LOCK_INFO_MAX_COUNT 50
54
#define LOCKLIST_ARG_SUFFIX(name) #name " in " __FUNCTION__ "() at " __FILE__ ":" QUOTE(__LINE__)
56
#define LOCKLIST_ARG_SUFFIX(name) #name " in " QUOTE(__PRETTY_FUNCTION__) "() at " QUOTE(__FILE__) ":" QUOTE(__LINE__)
60
* An instance of XTThreadLockInfo class keeps information about a lock kept by a thread.
61
* There's a list of XTThreadLockInfo instances per thread. An instance can be included
62
* into several thread lists in case of shared locks.
64
typedef struct XTThreadLockInfo {
66
enum LockType { SPIN_LOCK, MUTEX, RW_LOCK, FAST_RW_LOCK, SPIN_RW_LOCK };
68
LockType li_lock_type;
71
XTSpinLock *li_spin_lock; // SPIN_LOCK
72
XTMutexXSLock *li_fast_rwlock; // FAST_RW_LOCK
73
XTSpinXSLock *li_spin_rwlock; // SPIN_RW_LOCK
74
xt_mutex_struct *li_mutex; // MUTEX
75
xt_rwlock_struct *li_rwlock; // RW_LOCK
78
XTThreadLockInfoRec, *XTThreadLockInfoPtr;
80
void xt_thread_lock_info_init(XTThreadLockInfoPtr ptr, XTSpinLock *lock);
81
void xt_thread_lock_info_init(XTThreadLockInfoPtr ptr, XTMutexXSLock *lock);
82
void xt_thread_lock_info_init(XTThreadLockInfoPtr ptr, XTSpinXSLock *lock);
83
void xt_thread_lock_info_init(XTThreadLockInfoPtr ptr, xt_mutex_struct *lock);
84
void xt_thread_lock_info_init(XTThreadLockInfoPtr ptr, xt_rwlock_struct *lock);
85
void xt_thread_lock_info_free(XTThreadLockInfoPtr ptr);
87
void xt_thread_lock_info_add_owner (XTThreadLockInfoPtr ptr);
88
void xt_thread_lock_info_release_owner (XTThreadLockInfoPtr ptr);
90
void xt_trace_thread_locks(XTThread *self);
92
#endif // XT_THREAD_LOCK_INFO
93
#endif // __xt_locklist_h__