~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/current_session.cc

Merge Joe, plus I updated the tests.

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
20
20
#include "config.h"
21
21
#include <drizzled/current_session.h>
22
22
 
 
23
#include <pthread.h>
 
24
 
23
25
namespace drizzled
24
26
{
25
27
 
26
 
static MySessionVar THR_Session;
27
 
static MyMemoryRootVar THR_Mem_root;
28
 
 
29
 
MySessionVar &currentSession(void)
30
 
{
31
 
  return THR_Session;
32
 
}
33
 
 
34
 
MyMemoryRootVar &currentMemRoot(void)
35
 
{
36
 
  return THR_Mem_root;
37
 
}
 
28
extern pthread_key_t THR_Session;
 
29
extern pthread_key_t THR_Mem_root;
38
30
 
39
31
Session *_current_session(void)
40
32
{
41
 
  return THR_Session.get();
 
33
  return static_cast<Session *>(pthread_getspecific(THR_Session));
42
34
}
43
35
 
 
36
 
44
37
memory::Root *current_mem_root(void)
45
38
{
46
 
  return *(currentMemRoot().get());
 
39
  return *(static_cast<memory::Root **>(pthread_getspecific(THR_Mem_root)));
47
40
}
48
41
 
49
42
} /* namespace drizzled */