~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/multi_thread/multi_thread.cc

  • Committer: Brian Aker
  • Date: 2010-11-23 09:35:51 UTC
  • mfrom: (1933.2.13 catalogs)
  • Revision ID: brian@tangent.org-20101123093551-l5m7zhz3m5c4wmlk
Merge in changes for barriers (update for kill, etc).

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
  extern size_t my_thread_stack_size;
39
39
}
40
40
 
 
41
namespace multi_thread {
 
42
 
41
43
void MultiThreadScheduler::runSession(drizzled::session_id_t id)
42
44
{
43
45
  char stack_dummy;
 
46
  boost::this_thread::disable_interruption disable_by_default;
44
47
  Session::shared_ptr session(session::Cache::singleton().find(id));
45
48
 
46
49
  if (not session)
48
51
    std::cerr << "Session killed before thread could execute\n";
49
52
    return;
50
53
  }
 
54
  session->pushInterrupt(&disable_by_default);
51
55
 
52
56
  if (drizzled::internal::my_thread_init())
53
57
  {
110
114
 
111
115
  thread_count.increment();
112
116
 
113
 
  boost::thread new_thread(boost::bind(&MultiThreadScheduler::runSession, this, session->getSessionId()));
114
 
 
115
 
  if (not new_thread.joinable())
 
117
  session->getThread().reset(new boost::thread((boost::bind(&MultiThreadScheduler::runSession, this, session->getSessionId()))));
 
118
 
 
119
  if (not session->getThread())
 
120
  {
 
121
    thread_count.decrement();
 
122
    return true;
 
123
  }
 
124
 
 
125
  if (not session->getThread()->joinable())
116
126
  {
117
127
    thread_count.decrement();
118
128
    return true;
138
148
  }
139
149
}
140
150
 
 
151
} // multi_thread namespace
 
152
 
141
153
  
142
154
static int init(drizzled::module::Context &context)
143
155
{
144
156
  
145
 
  context.add(new MultiThreadScheduler("multi_thread"));
 
157
  context.add(new multi_thread::MultiThreadScheduler("multi_thread"));
146
158
 
147
159
  return 0;
148
160
}