~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/query_id.cc

  • Committer: Monty Taylor
  • Date: 2009-03-04 02:48:12 UTC
  • mto: (917.1.2 mordred)
  • mto: This revision was merged to the branch mainline in revision 918.
  • Revision ID: mordred@inaugust.com-20090304024812-5wb6wpye5c1iitbq
Applied atomic patch to current tree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#include <drizzled/definitions.h>
22
22
#include <drizzled/query_id.h>
23
23
#include <mysys/my_pthread.h>
 
24
#include <drizzled/atomics.h>
24
25
 
25
 
Query_id::Query_id() : the_query_id(1)
 
26
Query_id::Query_id()
26
27
{
27
 
  /* pthread_mutex_init always returns 0 */
28
 
  (void)pthread_mutex_init(&LOCK_query_id, MY_MUTEX_INIT_FAST);
 
28
  the_query_id= 1;
29
29
}
30
30
 
31
31
Query_id::~Query_id()
32
32
{
33
 
  pthread_mutex_destroy(&LOCK_query_id);
34
33
}
35
34
 
36
35
query_id_t Query_id::value() const
40
39
 
41
40
query_id_t Query_id::next()
42
41
{
43
 
  pthread_mutex_lock(&LOCK_query_id);
44
 
  query_id_t ret= the_query_id++;
45
 
  pthread_mutex_unlock(&LOCK_query_id);
46
 
 
47
 
  return ret;
 
42
  return ++the_query_id;
48
43
}
49
44