~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/query_id.cc

  • Committer: Lee
  • Date: 2008-10-30 22:02:01 UTC
  • mto: (572.1.2 devel)
  • mto: This revision was merged to the branch mainline in revision 573.
  • Revision ID: lbieber@lbieber-desktop-20081030220201-elb6qprbzpn7c5a4
add my name to the AUTHORS file

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include "config.h"
21
 
#include <drizzled/definitions.h>
 
20
#include <config.h>
 
21
#include <definitions.h>
22
22
#include <drizzled/query_id.h>
23
 
#include "drizzled/internal/my_pthread.h"
24
 
 
25
 
namespace drizzled
26
 
{
27
 
 
28
 
Query_id::Query_id()
29
 
{
30
 
  the_query_id= 1;
 
23
#include <mysys/my_pthread.h>
 
24
 
 
25
Query_id::Query_id() : the_query_id(1)
 
26
{
 
27
  /* pthread_mutex_init always returns 0 */
 
28
  (void)pthread_mutex_init(&LOCK_query_id, MY_MUTEX_INIT_FAST);
31
29
}
32
30
 
33
31
Query_id::~Query_id()
34
32
{
 
33
  pthread_mutex_destroy(&LOCK_query_id);
35
34
}
36
35
 
37
 
uint64_t Query_id::value() const
 
36
query_id_t Query_id::value() const
38
37
{
39
38
  return the_query_id;
40
39
}
41
40
 
42
 
uint64_t Query_id::next()
 
41
query_id_t Query_id::next()
43
42
{
44
 
  uint64_t ret= the_query_id.increment();
45
 
 
 
43
  pthread_mutex_lock(&LOCK_query_id);
 
44
  query_id_t ret= the_query_id++;
 
45
  pthread_mutex_unlock(&LOCK_query_id);
46
46
  return ret;
47
47
}
48
48
 
49
 
} /* namespace drizzled */