~posulliv/drizzle/optimizer-style-cleanup

« back to all changes in this revision

Viewing changes to plugin/pbxt/src/locklist_xt.h

  • Committer: Padraig O'Sullivan
  • Date: 2010-04-17 01:38:47 UTC
  • mfrom: (1237.9.238 bad-staging)
  • Revision ID: osullivan.padraig@gmail.com-20100417013847-ibjioqsfbmf5yg4g
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (c) 2009 PrimeBase Technologies GmbH
 
2
 *
 
3
 * PrimeBase XT
 
4
 *
 
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.
 
9
 *
 
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.
 
14
 *
 
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
 
18
 *
 
19
 * 2009-01-20   Vladimir Kolesnikov
 
20
 *
 
21
 * H&G2JCtL
 
22
 */
 
23
 
 
24
#ifndef __xt_locklist_h__
 
25
#define __xt_locklist_h__
 
26
 
 
27
/*
 
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()
 
30
 */
 
31
 
 
32
#ifdef DEBUG
 
33
//#define XT_THREAD_LOCK_INFO
 
34
#ifndef XT_WIN
 
35
/* We need DEBUG_LOCKING in order to enable pthread function wrappers */
 
36
//#define DEBUG_LOCKING
 
37
#endif
 
38
#endif
 
39
 
 
40
#include "xt_defs.h"
 
41
 
 
42
struct XTThread;
 
43
struct XTSpinLock;
 
44
struct xt_mutex_struct;
 
45
struct xt_rwlock_struct;
 
46
struct XTMutexXSLock;
 
47
struct XTSpinXSLock;
 
48
 
 
49
#ifdef XT_THREAD_LOCK_INFO
 
50
 
 
51
#define XT_THREAD_LOCK_INFO_MAX_COUNT 50
 
52
 
 
53
#ifdef XT_WIN
 
54
#define LOCKLIST_ARG_SUFFIX(name) #name " in " __FUNCTION__ "() at " __FILE__ ":" QUOTE(__LINE__)
 
55
#else
 
56
#define LOCKLIST_ARG_SUFFIX(name) #name " in " QUOTE(__PRETTY_FUNCTION__) "() at " QUOTE(__FILE__) ":" QUOTE(__LINE__)
 
57
#endif
 
58
 
 
59
/*
 
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.
 
63
 */
 
64
typedef struct XTThreadLockInfo {
 
65
 
 
66
        enum LockType { SPIN_LOCK, MUTEX, RW_LOCK, FAST_RW_LOCK, SPIN_RW_LOCK };
 
67
 
 
68
        LockType                  li_lock_type;
 
69
 
 
70
        union {
 
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
 
76
        };
 
77
 
78
XTThreadLockInfoRec, *XTThreadLockInfoPtr;
 
79
 
 
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);
 
86
 
 
87
void xt_thread_lock_info_add_owner (XTThreadLockInfoPtr ptr);
 
88
void xt_thread_lock_info_release_owner (XTThreadLockInfoPtr ptr);
 
89
 
 
90
void xt_trace_thread_locks(XTThread *self);
 
91
 
 
92
#endif // XT_THREAD_LOCK_INFO
 
93
#endif // __xt_locklist_h__