~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/thr_lock.cc

Merge Monty

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
 
66
66
*/
67
67
 
68
 
#include "drizzled/internal/mysys_priv.h"
 
68
#include "config.h"
 
69
#include "drizzled/internal/my_sys.h"
69
70
 
70
71
#include "thr_lock.h"
71
72
#include "drizzled/internal/m_string.h"
87
88
 
88
89
using namespace std;
89
90
 
 
91
namespace drizzled
 
92
{
 
93
 
90
94
bool thr_lock_inited= false;
91
95
uint32_t locks_immediate = 0L, locks_waited = 0L;
92
96
uint64_t table_lock_wait_timeout;
131
135
  lock->write_wait.last= &lock->write_wait.data;
132
136
  lock->write.last= &lock->write.data;
133
137
 
134
 
  pthread_mutex_lock(&THR_LOCK_lock);           /* Add to locks in use */
 
138
  pthread_mutex_lock(&internal::THR_LOCK_lock);         /* Add to locks in use */
135
139
  thr_lock_thread_list.push_front(lock);
136
 
  pthread_mutex_unlock(&THR_LOCK_lock);
 
140
  pthread_mutex_unlock(&internal::THR_LOCK_lock);
137
141
}
138
142
 
139
143
 
140
144
void thr_lock_delete(THR_LOCK *lock)
141
145
{
142
146
  pthread_mutex_destroy(&lock->mutex);
143
 
  pthread_mutex_lock(&THR_LOCK_lock);
 
147
  pthread_mutex_lock(&internal::THR_LOCK_lock);
144
148
  thr_lock_thread_list.remove(lock);
145
 
  pthread_mutex_unlock(&THR_LOCK_lock);
 
149
  pthread_mutex_unlock(&internal::THR_LOCK_lock);
146
150
}
147
151
 
148
152
 
149
153
void thr_lock_info_init(THR_LOCK_INFO *info)
150
154
{
151
 
  struct st_my_thread_var *tmp= my_thread_var;
 
155
  internal::st_my_thread_var *tmp= my_thread_var;
152
156
  info->thread= tmp->pthread_self;
153
157
  info->thread_id= tmp->id;
154
158
  info->n_cursors= 0;
184
188
wait_for_lock(struct st_lock_list *wait, THR_LOCK_DATA *data,
185
189
              bool in_wait_list)
186
190
{
187
 
  struct st_my_thread_var *thread_var= my_thread_var;
 
191
  internal::st_my_thread_var *thread_var= my_thread_var;
188
192
  pthread_cond_t *cond= &thread_var->suspend;
189
193
  struct timespec wait_timeout;
190
194
  enum enum_thr_lock_result result= THR_LOCK_ABORTED;
197
201
    wait->last= &data->next;
198
202
  }
199
203
 
200
 
  statistic_increment(locks_waited, &THR_LOCK_lock);
 
204
  statistic_increment(locks_waited, &internal::THR_LOCK_lock);
201
205
 
202
206
  /* Set up control struct to allow others to abort locks */
203
207
  thread_var->current_mutex= &data->lock->mutex;
305
309
          lock->read_no_write_count++;
306
310
        if (lock->get_status)
307
311
          (*lock->get_status)(data->status_param, 0);
308
 
        statistic_increment(locks_immediate,&THR_LOCK_lock);
 
312
        statistic_increment(locks_immediate,&internal::THR_LOCK_lock);
309
313
        goto end;
310
314
      }
311
315
      if (lock->write.data->type == TL_WRITE_ONLY)
327
331
        (*lock->get_status)(data->status_param, 0);
328
332
      if (lock_type == TL_READ_NO_INSERT)
329
333
        lock->read_no_write_count++;
330
 
      statistic_increment(locks_immediate,&THR_LOCK_lock);
 
334
      statistic_increment(locks_immediate,&internal::THR_LOCK_lock);
331
335
      goto end;
332
336
    }
333
337
    /*
376
380
        lock->write.last= &data->next;
377
381
        if (data->lock->get_status)
378
382
          (*data->lock->get_status)(data->status_param, 0);
379
 
        statistic_increment(locks_immediate,&THR_LOCK_lock);
 
383
        statistic_increment(locks_immediate,&internal::THR_LOCK_lock);
380
384
        goto end;
381
385
      }
382
386
    }
406
410
          lock->write.last= &data->next;
407
411
          if (data->lock->get_status)
408
412
            (*data->lock->get_status)(data->status_param, concurrent_insert);
409
 
          statistic_increment(locks_immediate,&THR_LOCK_lock);
 
413
          statistic_increment(locks_immediate,&internal::THR_LOCK_lock);
410
414
          goto end;
411
415
        }
412
416
      }
810
814
  pthread_mutex_unlock(&lock->mutex);
811
815
  return(found);
812
816
}
 
817
 
 
818
} /* namespace drizzled */