~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/multi_thread/multi_thread.cc

  • Committer: Olaf van der Spek
  • Date: 2011-07-04 19:11:47 UTC
  • mto: This revision was merged to the branch mainline in revision 2367.
  • Revision ID: olafvdspek@gmail.com-20110704191147-s99ojek811zi1fzj
RemoveĀ unusedĀ Name_resolution_context::error_reporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
   along with this program; if not, write to the Free Software
14
14
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
15
15
 
16
 
#include "config.h"
 
16
#include <config.h>
17
17
 
18
18
#include <iostream>
19
19
 
25
25
#include <drizzled/abort_exception.h>
26
26
#include <drizzled/transaction_services.h>
27
27
#include <drizzled/gettext.h>
 
28
#include <drizzled/plugin.h>
 
29
#include <drizzled/statistics_variables.h>
28
30
 
29
31
#include <boost/thread.hpp>
30
32
#include <boost/bind.hpp>
52
54
  char stack_dummy;
53
55
  boost::this_thread::disable_interruption disable_by_default;
54
56
 
55
 
  Session::shared_ptr session(session::Cache::singleton().find(id));
 
57
  Session::shared_ptr session(session::Cache::find(id));
56
58
 
57
59
  try
58
60
  {
63
65
      return;
64
66
    }
65
67
    session->pushInterrupt(&disable_by_default);
66
 
 
67
 
    if (drizzled::internal::my_thread_init())
68
 
    {
69
 
      session->disconnect(drizzled::ER_OUT_OF_RESOURCES);
70
 
      session->status_var.aborted_connects++;
71
 
    }
72
 
    else
73
 
    {
74
 
      boost::this_thread::at_thread_exit(&internal::my_thread_end);
75
 
 
76
 
      session->thread_stack= (char*) &stack_dummy;
77
 
      session->run();
78
 
    }
 
68
    drizzled::internal::my_thread_init();
 
69
    session->thread_stack= (char*) &stack_dummy;
 
70
    session->run();
79
71
 
80
72
    killSessionNow(session);
81
73
  }
86
78
    cout << _("In File: ") << *::boost::get_error_info<boost::throw_file>(ex) << endl;
87
79
    cout << _("On Line: ") << *::boost::get_error_info<boost::throw_line>(ex) << endl;
88
80
 
89
 
    TransactionServices::singleton().sendShutdownEvent(*session.get());
 
81
    TransactionServices::sendShutdownEvent(*session.get());
90
82
  }
91
83
  // @todo remove hard spin by disconnection the session first from the
92
84
  // thread.
131
123
#endif
132
124
}
133
125
 
134
 
bool MultiThreadScheduler::addSession(Session::shared_ptr &session)
 
126
bool MultiThreadScheduler::addSession(const Session::shared_ptr& session)
135
127
{
136
128
  if (thread_count >= max_threads)
137
129
    return true;
165
157
 
166
158
void MultiThreadScheduler::killSession(Session *session)
167
159
{
168
 
  boost_thread_shared_ptr thread(session->getThread());
 
160
  thread_ptr thread(session->getThread());
169
161
 
170
162
  if (thread)
171
163
  {
173
165
  }
174
166
}
175
167
 
176
 
void MultiThreadScheduler::killSessionNow(Session::shared_ptr &session)
 
168
void MultiThreadScheduler::killSessionNow(const Session::shared_ptr& session)
177
169
{
178
170
  killSession(session.get());
179
171
 
186
178
 
187
179
MultiThreadScheduler::~MultiThreadScheduler()
188
180
{
189
 
  boost::mutex::scoped_lock scopedLock(drizzled::session::Cache::singleton().mutex());
 
181
  boost::mutex::scoped_lock scopedLock(drizzled::session::Cache::mutex());
190
182
  while (thread_count)
191
183
  {
192
184
    COND_thread_count.wait(scopedLock);