~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/thr_lock.h

  • Committer: Brian Aker
  • Date: 2008-09-04 19:31:00 UTC
  • Revision ID: brian@tangent.org-20080904193100-l849hgghfy4urj43
Changing default character set from this point on.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
#include <mysys/my_pthread.h>
25
25
#include <mysys/my_list.h>
26
 
#include <mysys/definitions.h>
27
26
 
28
27
struct st_thr_lock;
29
28
extern uint32_t locks_immediate,locks_waited ;
30
29
extern pthread_mutex_t THR_LOCK_lock;
31
30
 
 
31
enum thr_lock_type { TL_IGNORE=-1,
 
32
                     TL_UNLOCK,                 /* UNLOCK ANY LOCK */
 
33
                     TL_READ,                   /* Read lock */
 
34
                     TL_READ_WITH_SHARED_LOCKS,
 
35
                     /* High prior. than TL_WRITE. Allow concurrent insert */
 
36
                     TL_READ_HIGH_PRIORITY,
 
37
                     /* READ, Don't allow concurrent insert */
 
38
                     TL_READ_NO_INSERT,
 
39
                     /* 
 
40
                        Write lock, but allow other threads to read / write.
 
41
                        Used by BDB tables in MySQL to mark that someone is
 
42
                        reading/writing to the table.
 
43
                      */
 
44
                     TL_WRITE_ALLOW_WRITE,
 
45
                     /*
 
46
                        Write lock, but allow other threads to read.
 
47
                        Used by ALTER TABLE in MySQL to allow readers
 
48
                        to use the table until ALTER TABLE is finished.
 
49
                     */
 
50
                     TL_WRITE_ALLOW_READ,
 
51
                     /*
 
52
                       WRITE lock used by concurrent insert. Will allow
 
53
                       READ, if one could use concurrent insert on table.
 
54
                     */
 
55
                     TL_WRITE_CONCURRENT_INSERT,
 
56
                     /* Write used by INSERT DELAYED.  Allows READ locks */
 
57
                     TL_WRITE_DELAYED,
 
58
                     /* 
 
59
                       parser only! Late bound low_priority flag. 
 
60
                       At open_tables() becomes thd->update_lock_default.
 
61
                     */
 
62
                     TL_WRITE_DEFAULT,
 
63
                     /* WRITE lock that has lower priority than TL_READ */
 
64
                     TL_WRITE_LOW_PRIORITY,
 
65
                     /* Normal WRITE lock */
 
66
                     TL_WRITE,
 
67
                     /* Abort new lock request with an error */
 
68
                     TL_WRITE_ONLY};
 
69
 
 
70
enum enum_thr_lock_result { THR_LOCK_SUCCESS= 0, THR_LOCK_ABORTED= 1,
 
71
                            THR_LOCK_WAIT_TIMEOUT= 2, THR_LOCK_DEADLOCK= 3 };
 
72
 
32
73
 
33
74
extern ulong max_write_lock_count;
34
75
extern ulong table_lock_wait_timeout;
81
122
  struct st_lock_list write;
82
123
  /* write_lock_count is incremented for write locks and reset on read locks */
83
124
  uint32_t write_lock_count;
84
 
  uint32_t read_no_write_count;
 
125
  uint read_no_write_count;
85
126
  void (*get_status)(void*, int);       /* When one gets a lock */
86
127
  void (*copy_status)(void*,void*);
87
128
  void (*update_status)(void*);         /* Before release of write */
104
145
                                   enum thr_lock_type lock_type);
105
146
void thr_unlock(THR_LOCK_DATA *data);
106
147
enum enum_thr_lock_result thr_multi_lock(THR_LOCK_DATA **data,
107
 
                                         uint32_t count, THR_LOCK_OWNER *owner);
108
 
void thr_multi_unlock(THR_LOCK_DATA **data,uint32_t count);
 
148
                                         uint count, THR_LOCK_OWNER *owner);
 
149
void thr_multi_unlock(THR_LOCK_DATA **data,uint count);
109
150
void thr_abort_locks(THR_LOCK *lock, bool upgrade_lock);
110
151
bool thr_abort_locks_for_thread(THR_LOCK *lock, my_thread_id thread);
111
152
bool thr_upgrade_write_delay_lock(THR_LOCK_DATA *data);