blob: 71c8817c5edd5fc85715b8bac2110611dbbff05d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
// file : odb/session.cxx
// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#include <odb/exceptions.hxx>
#include <odb/session.hxx>
#include <odb/details/tls.hxx>
namespace odb
{
using namespace details;
static ODB_TLS_POINTER (session) current_session;
session::
session ()
{
if (has_current ())
throw already_in_session ();
current (*this);
}
session::
~session ()
{
// If we are the current thread's session, reset it.
//
if (has_current () && ¤t () == this)
reset_current ();
}
bool session::
has_current ()
{
return tls_get (current_session) != 0;
}
session& session::
current ()
{
session* cur (tls_get (current_session));
if (cur == 0)
throw not_in_session ();
return *cur;
}
void session::
current (session& s)
{
tls_set (current_session, &s);
}
void session::
reset_current ()
{
session* s (0);
tls_set (current_session, s);
}
//
// object_map_base
//
session::object_map_base::
~object_map_base ()
{
}
}
|