~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/thr_lock.cc

  • Committer: Brian Aker
  • Date: 2010-11-29 07:05:33 UTC
  • mfrom: (1960.1.2 refactor)
  • Revision ID: brian@tangent.org-20101129070533-grqo3e8by2wqqpcd
Rollup of scoped lock.

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
#include "drizzled/pthread_globals.h"
60
60
 
61
61
#include "drizzled/session.h"
62
 
#include "drizzled/current_session.h"
63
62
 
64
63
#include "thr_lock.h"
65
64
#include "drizzled/internal/m_string.h"
150
149
static void wake_up_waiters(THR_LOCK *lock);
151
150
 
152
151
 
153
 
static enum enum_thr_lock_result wait_for_lock(struct st_lock_list *wait, THR_LOCK_DATA *data, bool in_wait_list)
 
152
static enum enum_thr_lock_result wait_for_lock(Session &session, struct st_lock_list *wait, THR_LOCK_DATA *data)
154
153
{
155
 
  Session *session= current_session;
156
 
  internal::st_my_thread_var *thread_var= session->getThreadVar();
 
154
  internal::st_my_thread_var *thread_var= session.getThreadVar();
157
155
 
158
156
  boost::condition_variable_any *cond= &thread_var->suspend;
159
157
  enum enum_thr_lock_result result= THR_LOCK_ABORTED;
160
158
  bool can_deadlock= test(data->owner->info->n_cursors);
161
159
 
162
 
  if (!in_wait_list)
163
160
  {
164
161
    (*wait->last)=data;                         /* Wait for lock */
165
162
    data->prev= wait->last;
173
170
  thread_var->current_cond=  &thread_var->suspend;
174
171
  data->cond= &thread_var->suspend;;
175
172
 
176
 
  while (!thread_var->abort || in_wait_list)
 
173
  while (not thread_var->abort)
177
174
  {
178
175
    boost_unique_lock_t scoped(*data->lock->native_handle(), boost::adopt_lock_t());
179
176
 
239
236
}
240
237
 
241
238
 
242
 
static enum enum_thr_lock_result thr_lock(THR_LOCK_DATA *data, THR_LOCK_OWNER *owner, enum thr_lock_type lock_type)
 
239
static enum enum_thr_lock_result thr_lock(Session &session, THR_LOCK_DATA *data, THR_LOCK_OWNER *owner, enum thr_lock_type lock_type)
243
240
{
244
241
  THR_LOCK *lock= data->lock;
245
242
  enum enum_thr_lock_result result= THR_LOCK_SUCCESS;
387
384
  }
388
385
 
389
386
  /* Can't get lock yet;  Wait for it */
390
 
  return(wait_for_lock(wait_queue, data, 0));
 
387
  return(wait_for_lock(session, wait_queue, data));
391
388
end:
392
389
  lock->unlock();
393
390
 
594
591
 
595
592
 
596
593
enum enum_thr_lock_result
597
 
thr_multi_lock(THR_LOCK_DATA **data, uint32_t count, THR_LOCK_OWNER *owner)
 
594
thr_multi_lock(Session &session, THR_LOCK_DATA **data, uint32_t count, THR_LOCK_OWNER *owner)
598
595
{
599
596
  THR_LOCK_DATA **pos,**end;
600
597
  if (count > 1)
602
599
  /* lock everything */
603
600
  for (pos=data,end=data+count; pos < end ; pos++)
604
601
  {
605
 
    enum enum_thr_lock_result result= thr_lock(*pos, owner, (*pos)->type);
 
602
    enum enum_thr_lock_result result= thr_lock(session, *pos, owner, (*pos)->type);
606
603
    if (result != THR_LOCK_SUCCESS)
607
604
    {                                           /* Aborted */
608
605
      thr_multi_unlock(data,(uint32_t) (pos-data));