Drizzled Public API Documentation

barrier_dictionary.cc

00001 /* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2010 Brian Aker
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019  */
00020 
00021 #include <config.h>
00022 
00023 #include <plugin/user_locks/module.h>
00024 
00025 #include <drizzled/atomics.h>
00026 #include <drizzled/session.h>
00027 
00028 using namespace drizzled;
00029 using namespace std;
00030 
00031 namespace user_locks {
00032 namespace barriers {
00033 
00034 UserBarriers::UserBarriers() :
00035   plugin::TableFunction("DATA_DICTIONARY", "USER_DEFINED_BARRIERS")
00036 {
00037   add_field("USER_BARRIER_NAME", plugin::TableFunction::STRING, LARGEST_LOCK_NAME, false);
00038   add_field("SESSION_ID", plugin::TableFunction::NUMBER, 0, false);
00039   add_field("USER_NAME", plugin::TableFunction::STRING);
00040   add_field("WAITER_LIMIT", plugin::TableFunction::NUMBER, 0, false);
00041   add_field("GENERATION", plugin::TableFunction::NUMBER, 0, false);
00042   add_field("WAITERS", plugin::TableFunction::NUMBER, 0, false);
00043   add_field("OBSERVERS", plugin::TableFunction::NUMBER, 0, false);
00044 }
00045 
00046 UserBarriers::Generator::Generator(drizzled::Field **arg) :
00047   drizzled::plugin::TableFunction::Generator(arg)
00048 {
00049   Barriers::getInstance().Copy(barrier_map);
00050   iter= barrier_map.begin();
00051 }
00052 
00053 bool UserBarriers::Generator::populate()
00054 {
00055 
00056   while (iter != barrier_map.end())
00057   {
00058     // USER_BARRIER_NAME
00059     push(iter->first.getLockName());
00060 
00061     // SESSION_ID
00062     push(iter->second->getOwner());
00063      
00064     // USER_NAME
00065     push(iter->first.getUser());
00066     
00067     // WAITER_LIMIT
00068     push(iter->second->getLimit());
00069     
00070     // GENERATION
00071     push(iter->second->getGeneration());
00072     
00073     // WAITERS
00074     push(iter->second->sizeWaiters());
00075     
00076     // OBSERVERS
00077     push(iter->second->sizeObservers());
00078 
00079     iter++;
00080     return true;
00081   }
00082 
00083   return false;
00084 }
00085 
00086 } /* namespace barriers */
00087 } /* namespace user_locks */