~posulliv/drizzle/optimizer-style-cleanup

« back to all changes in this revision

Viewing changes to plugin/pool_of_threads/pool_of_threads.cc

  • Committer: Padraig O'Sullivan
  • Date: 2010-04-17 01:38:47 UTC
  • mfrom: (1237.9.238 bad-staging)
  • Revision ID: osullivan.padraig@gmail.com-20100417013847-ibjioqsfbmf5yg4g
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
static volatile bool kill_pool_threads= false;
37
37
 
38
38
static volatile uint32_t created_threads= 0;
39
 
static int deinit(drizzled::plugin::Registry &registry);
40
39
 
41
40
static struct event session_add_event;
42
41
static struct event session_kill_event;
57
56
  void libevent_kill_session_callback(int Fd, short Operation, void *ctx);
58
57
}
59
58
 
60
 
static uint32_t size= 0;
 
59
static uint32_t pool_size= 0;
61
60
 
62
61
/**
63
62
 * @brief 
323
322
  */
324
323
  (void) pthread_mutex_lock(&LOCK_thread_count);
325
324
  created_threads++;
326
 
  if (created_threads == size)
 
325
  if (created_threads == pool_size)
327
326
    (void) pthread_cond_signal(&COND_thread_count);
328
327
  (void) pthread_mutex_unlock(&LOCK_thread_count);
329
328
 
609
608
  /* Set up the thread pool */
610
609
  pthread_mutex_lock(&LOCK_thread_count);
611
610
 
612
 
  for (x= 0; x < size; x++)
 
611
  for (x= 0; x < pool_size; x++)
613
612
  {
614
613
    pthread_t thread;
615
614
    int error;
623
622
  }
624
623
 
625
624
  /* Wait until all threads are created */
626
 
  while (created_threads != size)
 
625
  while (created_threads != pool_size)
627
626
    pthread_cond_wait(&COND_thread_count,&LOCK_thread_count);
628
627
  pthread_mutex_unlock(&LOCK_thread_count);
629
628
 
637
636
 * 
638
637
 * @param[in] registry holding the record of the plugins
639
638
 */
640
 
static int init(drizzled::plugin::Registry &registry)
 
639
static int init(drizzled::plugin::Context &context)
641
640
{
642
 
  assert(size != 0);
 
641
  assert(pool_size != 0);
643
642
 
644
643
  scheduler= new PoolOfThreadsScheduler("pool_of_threads");
645
 
  registry.add(scheduler);
646
 
 
647
 
  return 0;
648
 
}
649
 
 
650
 
/**
651
 
 * @brief
652
 
 *  Waits until all pool threads have been deleted for clean shutdown
653
 
 */
654
 
static int deinit(drizzled::plugin::Registry &registry)
655
 
{
656
 
  registry.remove(scheduler);
657
 
  delete scheduler;
 
644
  context.add(scheduler);
658
645
 
659
646
  return 0;
660
647
}
663
650
 The defaults here were picked based on what I see (aka Brian). They should
664
651
 be vetted across a larger audience.
665
652
*/
666
 
static DRIZZLE_SYSVAR_UINT(size, size,
 
653
static DRIZZLE_SYSVAR_UINT(size, pool_size,
667
654
                           PLUGIN_VAR_RQCMDARG,
668
655
                           N_("Size of Pool."),
669
656
                           NULL, NULL, 8, 1, 1024, 0);
682
669
  "Pool of Threads Scheduler",
683
670
  PLUGIN_LICENSE_GPL,
684
671
  init, /* Plugin Init */
685
 
  deinit, /* Plugin Deinit */
686
672
  sys_variables,   /* system variables */
687
673
  NULL    /* config options */
688
674
}