~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/pool_of_threads/pool_of_threads.cc

  • Committer: Monty Taylor
  • Date: 2009-04-10 18:17:59 UTC
  • mto: (992.1.1 mordred)
  • mto: This revision was merged to the branch mainline in revision 990.
  • Revision ID: mordred@inaugust.com-20090410181759-wr58on1xxc9lwzut
Made plugin registration go through Plugin_registry.

Show diffs side-by-side

added added

removed removed

Lines of Context:
394
394
  }
395
395
}; 
396
396
 
 
397
 
 
398
class PoolOfThreadsFactory : public SchedulerFactory
 
399
{
 
400
public:
 
401
  PoolOfThreadsFactory() : SchedulerFactory("pool_of_threads") {}
 
402
  ~PoolOfThreadsFactory() { if (scheduler != NULL) delete scheduler; }
 
403
  Scheduler *operator() ()
 
404
  {
 
405
    if (scheduler == NULL)
 
406
    {
 
407
      Pool_of_threads_scheduler *pot= new Pool_of_threads_scheduler(size);
 
408
      if (pot->libevent_init())
 
409
      {
 
410
        delete pot;
 
411
        return NULL;
 
412
      }
 
413
      scheduler= pot;
 
414
    }
 
415
    return scheduler;
 
416
  }
 
417
};
 
418
 
397
419
/*
398
420
  Close and delete a connection.
399
421
*/
593
615
{
594
616
  assert(size != 0);
595
617
 
596
 
  void **plugin= static_cast<void **>(p);
597
 
 
598
 
  Pool_of_threads_scheduler *sched=
599
 
    new Pool_of_threads_scheduler(size);
600
 
  if (sched->libevent_init())
601
 
  {
602
 
    delete sched;
603
 
    return 1;
604
 
  }
605
 
 
606
 
  *plugin= static_cast<void *>(sched);
 
618
  SchedulerFactory **plugin= static_cast<SchedulerFactory **>(p);
 
619
 
 
620
  PoolOfThreadsFactory *factory=
 
621
    new PoolOfThreadsFactory();
 
622
 
 
623
  *plugin= factory;
607
624
 
608
625
  return 0;
609
626
}
614
631
 
615
632
static int deinit(void *p)
616
633
{
617
 
  Scheduler *sched= static_cast<Scheduler *>(p);
618
 
  delete sched;
 
634
  PoolOfThreadsFactory *factory= static_cast<PoolOfThreadsFactory *>(p);
 
635
  delete factory;
619
636
 
620
637
  return 0;
621
638
}