13
13
along with this program; if not, write to the Free Software
14
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
16
/* For use with thr_locks */
18
#ifndef DRIZZLED_THR_LOCK_H
19
#define DRIZZLED_THR_LOCK_H
16
/* For use with thr_lock:s */
24
#include <mysys/my_pthread.h>
25
#include <mysys/definitions.h>
26
27
struct st_thr_lock;
27
28
extern uint32_t locks_immediate,locks_waited ;
31
29
extern pthread_mutex_t THR_LOCK_lock;
34
32
extern uint64_t max_write_lock_count;
35
33
extern uint64_t table_lock_wait_timeout;
36
34
extern bool thr_lock_inited;
39
enum thr_lock_type { TL_IGNORE=-1,
44
TL_READ_WITH_SHARED_LOCKS,
45
/* READ, Don't allow concurrent insert */
48
Write lock, but allow other threads to read / write.
49
Used by BDB tables in MySQL to mark that someone is
50
reading/writing to the table.
54
Write lock, but allow other threads to read.
55
Used by ALTER TABLE in MySQL to allow readers
56
to use the table until ALTER TABLE is finished.
60
WRITE lock used by concurrent insert. Will allow
61
READ, if one could use concurrent insert on table.
63
TL_WRITE_CONCURRENT_INSERT,
65
parser only! Late bound low_priority flag.
66
At open_tables() becomes thd->update_lock_default.
69
/* Normal WRITE lock */
71
/* Abort new lock request with an error */
74
enum enum_thr_lock_result { THR_LOCK_SUCCESS= 0, THR_LOCK_ABORTED= 1,
75
THR_LOCK_WAIT_TIMEOUT= 2, THR_LOCK_DEADLOCK= 3 };
35
extern enum thr_lock_type thr_upgraded_concurrent_insert_lock;
77
38
A description of the thread which owns the lock. The address
78
39
of an instance of this structure is used to uniquely identify the thread.
134
95
void thr_lock_delete(THR_LOCK *lock);
135
96
void thr_lock_data_init(THR_LOCK *lock,THR_LOCK_DATA *data,
136
97
void *status_param);
98
enum enum_thr_lock_result thr_lock(THR_LOCK_DATA *data,
99
THR_LOCK_OWNER *owner,
100
enum thr_lock_type lock_type);
101
void thr_unlock(THR_LOCK_DATA *data);
137
102
enum enum_thr_lock_result thr_multi_lock(THR_LOCK_DATA **data,
138
103
uint32_t count, THR_LOCK_OWNER *owner);
139
104
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
} /* namespace drizzled */
145
#endif /* DRIZZLED_THR_LOCK_H */
105
void thr_abort_locks(THR_LOCK *lock, bool upgrade_lock);
106
bool thr_abort_locks_for_thread(THR_LOCK *lock, my_thread_id thread);
110
#endif /* _thr_lock_h */