~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table/instance/shared.cc

  • Committer: Lee Bieber
  • Date: 2011-04-14 16:20:43 UTC
  • mfrom: (2277.1.3 build)
  • Revision ID: kalebral@gmail.com-20110414162043-2khq8mql7gvodnzn
Merge Olaf - Refactor Session Cache and Remove table::Cache::singleton()
Merge Olaf - Refactor Thread
Merge Olaf - remove unused functions

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include <drizzled/table/instance/shared.h>
28
28
#include <drizzled/plugin/storage_engine.h>
29
29
 
30
 
namespace drizzled
31
 
{
32
 
 
33
 
namespace table
34
 
{
35
 
 
36
 
namespace instance
37
 
{
 
30
namespace drizzled {
 
31
namespace table {
 
32
namespace instance {
38
33
 
39
34
Shared::Shared(const identifier::Table::Type type_arg,
40
35
               const identifier::Table &identifier,
107
102
  If it doesn't exist, create a new from the table definition file.
108
103
 
109
104
  NOTES
110
 
  We must have wrlock on table::Cache::singleton().mutex() when we come here
 
105
  We must have wrlock on table::Cache::mutex() when we come here
111
106
  (To be changed later)
112
107
 
113
108
  RETURN
124
119
  in_error= 0;
125
120
 
126
121
  /* Read table definition from cache */
127
 
  if ((share= definition::Cache::singleton().find(identifier.getKey())))
 
122
  if ((share= definition::Cache::find(identifier.getKey())))
128
123
    return foundTableShare(share);
129
124
  
130
125
  drizzled::message::schema::shared_ptr schema_message_ptr= plugin::StorageEngine::getSchemaDefinition(identifier);
147
142
  
148
143
  plugin::EventObserver::registerTableEvents(*share);
149
144
 
150
 
  bool ret= definition::Cache::singleton().insert(identifier.getKey(), share);
 
145
  bool ret= definition::Cache::insert(identifier.getKey(), share);
151
146
 
152
147
  if (not ret)
153
148
  {
184
179
void release(TableShare *share)
185
180
{
186
181
  bool to_be_deleted= false;
187
 
  //safe_mutex_assert_owner(table::Cache::singleton().mutex().native_handle);
 
182
  //safe_mutex_assert_owner(table::Cache::mutex().native_handle);
188
183
 
189
184
  share->lock();
190
185
  if (not share->decrementTableCount())
195
190
 
196
191
  if (to_be_deleted)
197
192
  {
198
 
    definition::Cache::singleton().erase(share->getCacheKey());
 
193
    definition::Cache::erase(share->getCacheKey());
199
194
  }
200
195
}
201
196
 
203
198
{
204
199
  bool to_be_deleted= false;
205
200
#if 0
206
 
  safe_mutex_assert_owner(table::Cache::singleton().mutex().native_handle);
 
201
  safe_mutex_assert_owner(table::Cache::mutex().native_handle);
207
202
#endif
208
203
 
209
204
  share->lock();
215
210
 
216
211
  if (to_be_deleted)
217
212
  {
218
 
    definition::Cache::singleton().erase(share->getCacheKey());
 
213
    definition::Cache::erase(share->getCacheKey());
219
214
  }
220
215
}
221
216
 
222
217
void release(const identifier::Table &identifier)
223
218
{
224
 
  TableShare::shared_ptr share= definition::Cache::singleton().find(identifier.getKey());
 
219
  TableShare::shared_ptr share= definition::Cache::find(identifier.getKey());
225
220
  if (share)
226
221
  {
227
222
    share->resetVersion(); 
228
223
    if (share->getTableCount() == 0)
229
224
    {
230
 
      definition::Cache::singleton().erase(identifier.getKey());
 
225
      definition::Cache::erase(identifier.getKey());
231
226
    }
232
227
  }
233
228
}