12
12
You should have received a copy of the GNU General Public License
13
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
14
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
16
16
/* For use with thr_locks */
18
18
#ifndef DRIZZLED_THR_LOCK_H
19
19
#define DRIZZLED_THR_LOCK_H
21
#include <boost/thread/mutex.hpp>
22
#include <boost/thread/shared_mutex.hpp>
23
#include <boost/thread/condition_variable.hpp>
25
#include "drizzled/visibility.h"
27
extern uint32_t locks_immediate,locks_waited ;
31
extern pthread_mutex_t THR_LOCK_lock;
34
30
extern uint64_t max_write_lock_count;
35
31
extern uint64_t table_lock_wait_timeout;
36
extern bool thr_lock_inited;
39
34
enum thr_lock_type { TL_IGNORE=-1,
91
93
structure is used as id.
94
typedef struct st_thr_lock_owner
96
98
THR_LOCK_INFO *info;
100
typedef struct st_thr_lock_data {
107
struct THR_LOCK_DATA;
109
struct DRIZZLED_API THR_LOCK_DATA {
101
110
THR_LOCK_OWNER *owner;
102
struct st_thr_lock_data *next,**prev;
103
struct st_thr_lock *lock;
104
pthread_cond_t *cond;
111
struct THR_LOCK_DATA *next,**prev;
112
struct THR_LOCK *lock;
113
boost::condition_variable_any *cond;
105
114
enum thr_lock_type type;
106
115
void *status_param; /* Param to status functions */
127
void init(THR_LOCK *lock,
128
void *status_param= NULL);
109
131
struct st_lock_list {
110
132
THR_LOCK_DATA *data,**last;
113
typedef struct st_thr_lock {
114
pthread_mutex_t mutex;
115
144
struct st_lock_list read_wait;
116
145
struct st_lock_list read;
117
146
struct st_lock_list write_wait;
119
148
/* write_lock_count is incremented for write locks and reset on read locks */
120
149
uint32_t write_lock_count;
121
150
uint32_t read_no_write_count;
122
void (*get_status)(void*, int); /* When one gets a lock */
123
void (*copy_status)(void*,void*);
124
void (*update_status)(void*); /* Before release of write */
125
void (*restore_status)(void*); /* Before release of read */
126
bool (*check_status)(void *);
130
bool init_thr_lock(void); /* Must be called once/thread */
154
read_no_write_count(0)
161
bool abort_locks_for_thread(uint64_t thread);
181
boost::mutex *native_handle()
131
189
#define thr_lock_owner_init(owner, info_arg) (owner)->info= (info_arg)
132
void thr_lock_info_init(THR_LOCK_INFO *info);
133
void thr_lock_init(THR_LOCK *lock);
134
void thr_lock_delete(THR_LOCK *lock);
135
void thr_lock_data_init(THR_LOCK *lock,THR_LOCK_DATA *data,
137
enum enum_thr_lock_result thr_multi_lock(THR_LOCK_DATA **data,
190
DRIZZLED_API void thr_lock_init(THR_LOCK *lock);
191
enum enum_thr_lock_result thr_multi_lock(Session &session, THR_LOCK_DATA **data,
138
192
uint32_t count, THR_LOCK_OWNER *owner);
139
193
void thr_multi_unlock(THR_LOCK_DATA **data,uint32_t count);
140
void thr_abort_locks(THR_LOCK *lock);
141
bool thr_abort_locks_for_thread(THR_LOCK *lock, uint64_t thread);
143
195
} /* namespace drizzled */