~posulliv/drizzle/memcached_applier

« back to all changes in this revision

Viewing changes to mysys/thr_lock.cc

mergeĀ fromĀ lp

Show diffs side-by-side

added added

removed removed

Lines of Context:
87
87
 
88
88
using namespace std;
89
89
 
90
 
bool thr_lock_inited=0;
 
90
bool thr_lock_inited= false;
91
91
uint32_t locks_immediate = 0L, locks_waited = 0L;
92
92
uint64_t table_lock_wait_timeout;
93
93
enum thr_lock_type thr_upgraded_concurrent_insert_lock = TL_WRITE;
108
108
 
109
109
bool init_thr_lock()
110
110
{
111
 
  thr_lock_inited=1;
112
 
  return 0;
 
111
  thr_lock_inited= true;
 
112
 
 
113
  return false;
113
114
}
114
115
 
115
116
static inline bool
133
134
  pthread_mutex_lock(&THR_LOCK_lock);           /* Add to locks in use */
134
135
  thr_lock_thread_list.push_front(lock);
135
136
  pthread_mutex_unlock(&THR_LOCK_lock);
136
 
  return;
137
137
}
138
138
 
139
139
 
143
143
  pthread_mutex_lock(&THR_LOCK_lock);
144
144
  thr_lock_thread_list.remove(lock);
145
145
  pthread_mutex_unlock(&THR_LOCK_lock);
146
 
  return;
147
146
}
148
147
 
149
148
 
150
149
void thr_lock_info_init(THR_LOCK_INFO *info)
151
150
{
152
151
  struct st_my_thread_var *tmp= my_thread_var;
153
 
  info->thread=    tmp->pthread_self;
 
152
  info->thread= tmp->pthread_self;
154
153
  info->thread_id= tmp->id;
155
154
  info->n_cursors= 0;
156
155
}
159
158
 
160
159
void thr_lock_data_init(THR_LOCK *lock,THR_LOCK_DATA *data, void *param)
161
160
{
162
 
  data->lock=lock;
163
 
  data->type=TL_UNLOCK;
164
 
  data->owner= 0;                               /* no owner yet */
165
 
  data->status_param=param;
166
 
  data->cond=0;
 
161
  data->lock= lock;
 
162
  data->type= TL_UNLOCK;
 
163
  data->owner= NULL;                               /* no owner yet */
 
164
  data->status_param= param;
 
165
  data->cond= NULL;
167
166
}
168
167
 
169
168
 
173
172
  for ( ; data ; data=data->next)
174
173
  {
175
174
    if (thr_lock_owner_equal(data->owner, owner))
176
 
      return 1;                                 /* Already locked by thread */
 
175
      return true;                                      /* Already locked by thread */
177
176
  }
178
 
  return 0;
 
177
  return false;
179
178
}
180
179
 
181
180
static void wake_up_waiters(THR_LOCK *lock);
260
259
 
261
260
  /* The following must be done after unlock of lock->mutex */
262
261
  pthread_mutex_lock(&thread_var->mutex);
263
 
  thread_var->current_mutex= 0;
264
 
  thread_var->current_cond=  0;
 
262
  thread_var->current_mutex= NULL;
 
263
  thread_var->current_cond= NULL;
265
264
  pthread_mutex_unlock(&thread_var->mutex);
266
265
  return(result);
267
266
}
745
744
 
746
745
  for (data=lock->read_wait.data; data ; data=data->next)
747
746
  {
748
 
    data->type=TL_UNLOCK;                       /* Mark killed */
 
747
    data->type= TL_UNLOCK;                      /* Mark killed */
749
748
    /* It's safe to signal the cond first: we're still holding the mutex. */
750
749
    pthread_cond_signal(data->cond);
751
 
    data->cond=0;                               /* Removed from list */
 
750
    data->cond= NULL;                           /* Removed from list */
752
751
  }
753
752
  for (data=lock->write_wait.data; data ; data=data->next)
754
753
  {
755
754
    data->type=TL_UNLOCK;
756
755
    pthread_cond_signal(data->cond);
757
 
    data->cond=0;
 
756
    data->cond= NULL;
758
757
  }
759
758
  lock->read_wait.last= &lock->read_wait.data;
760
759
  lock->write_wait.last= &lock->write_wait.data;
801
800
      data->type= TL_UNLOCK;
802
801
      found= true;
803
802
      pthread_cond_signal(data->cond);
804
 
      data->cond= 0;
 
803
      data->cond= NULL;
805
804
 
806
805
      if (((*data->prev)= data->next))
807
806
        data->next->prev= data->prev;