MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NdbPool.cpp
1 /*
2  Copyright (C) 2003, 2005, 2006 MySQL AB
3  All rights reserved. Use is subject to license terms.
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; version 2 of the License.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 #include <Ndb.hpp>
20 #include "NdbPoolImpl.hpp"
21 #include <NdbPool.hpp>
22 
23 static NdbPool* m_pool = 0;
24 
25 bool
27  Uint32 max_ndb_objects,
28  Uint32 no_conn_obj,
29  Uint32 init_no_ndb_objects)
30 {
31  if (m_pool != NULL) {
32  return false;
33  }
34  m_pool = NdbPool::create_instance(cc,
35  max_ndb_objects,
36  no_conn_obj,
37  init_no_ndb_objects);
38  if (m_pool == NULL) {
39  return false;
40  }
41  return true;
42 }
43 
44 void
45 drop_instance()
46 {
47  if (m_pool == NULL) {
48  return;
49  }
50  NdbPool::drop_instance();
51  m_pool = NULL;
52 }
53 
54 Ndb*
55 get_ndb_object(Uint32 &hint_id,
56  const char* a_catalog_name,
57  const char* a_schema_name)
58 {
59  if (m_pool == NULL) {
60  return NULL;
61  }
62  return m_pool->get_ndb_object(hint_id, a_catalog_name, a_schema_name);
63 }
64 
65 void
66 return_ndb_object(Ndb* returned_object, Uint32 id)
67 {
68  if (m_pool == NULL) {
69  return;
70  }
71  m_pool->return_ndb_object(returned_object, id);
72 }
73