~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/multi_thread/multi_thread.cc

  • Committer: Jay Pipes
  • Date: 2009-03-20 10:06:30 UTC
  • mfrom: (950 drizzle)
  • mto: This revision was merged to the branch mainline in revision 957.
  • Revision ID: jpipes@serialcoder-20090320100630-ra870urs5tz2g1b4
Merge with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
15
15
 
16
16
#include <drizzled/server_includes.h>
 
17
#include <drizzled/atomics.h>
17
18
#include <drizzled/gettext.h>
18
19
#include <drizzled/error.h>
19
20
#include <drizzled/plugin_scheduling.h>
26
27
 
27
28
pthread_attr_t multi_thread_attrib;
28
29
static uint32_t max_threads;
29
 
static volatile uint32_t thread_count;
 
30
static tbb::atomic<uint32_t> thread_count;
30
31
 
31
32
static bool add_connection(Session *session)
32
33
{
33
34
  int error;
34
35
 
35
36
  safe_mutex_assert_owner(&LOCK_thread_count);
 
37
  (void) pthread_mutex_unlock(&LOCK_thread_count);
36
38
  thread_count++;
37
 
  (void) pthread_mutex_unlock(&LOCK_thread_count);
38
39
 
39
40
  if ((error= pthread_create(&session->real_id, &multi_thread_attrib, handle_one_connection, (void*) session)))
40
41
    return true;
51
52
{
52
53
  unlink_session(session);   /* locks LOCK_thread_count and deletes session */
53
54
  thread_count--;
54
 
  pthread_mutex_unlock(&LOCK_thread_count);
55
55
 
56
56
  my_thread_end();
57
57
  pthread_exit(0);