drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
barrier_dictionary.cc
1/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3 *
4 * Copyright (C) 2010 Brian Aker
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include <config.h>
22
23#include <plugin/user_locks/module.h>
24
25#include <drizzled/atomics.h>
26#include <drizzled/session.h>
27
28using namespace drizzled;
29using namespace std;
30
31namespace user_locks {
32namespace barriers {
33
34UserBarriers::UserBarriers() :
35 plugin::TableFunction("DATA_DICTIONARY", "USER_DEFINED_BARRIERS")
36{
37 add_field("USER_BARRIER_NAME", plugin::TableFunction::STRING, LARGEST_LOCK_NAME, false);
38 add_field("SESSION_ID", plugin::TableFunction::NUMBER, 0, false);
39 add_field("USER_NAME", plugin::TableFunction::STRING);
40 add_field("WAITER_LIMIT", plugin::TableFunction::NUMBER, 0, false);
41 add_field("GENERATION", plugin::TableFunction::NUMBER, 0, false);
42 add_field("WAITERS", plugin::TableFunction::NUMBER, 0, false);
43 add_field("OBSERVERS", plugin::TableFunction::NUMBER, 0, false);
44}
45
46UserBarriers::Generator::Generator(drizzled::Field **arg) :
47 drizzled::plugin::TableFunction::Generator(arg)
48{
49 Barriers::getInstance().Copy(barrier_map);
50 iter= barrier_map.begin();
51}
52
53bool UserBarriers::Generator::populate()
54{
55
56 while (iter != barrier_map.end())
57 {
58 // USER_BARRIER_NAME
59 push(iter->first.getLockName());
60
61 // SESSION_ID
62 push(iter->second->getOwner());
63
64 // USER_NAME
65 push(iter->first.getUser());
66
67 // WAITER_LIMIT
68 push(iter->second->getLimit());
69
70 // GENERATION
71 push(iter->second->getGeneration());
72
73 // WAITERS
74 push(iter->second->sizeWaiters());
75
76 // OBSERVERS
77 push(iter->second->sizeObservers());
78
79 iter++;
80 return true;
81 }
82
83 return false;
84}
85
86} /* namespace barriers */
87} /* namespace user_locks */
TODO: Rename this file - func.h is stupid.
STL namespace.