~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table_share.cc

  • Committer: Brian Aker
  • Date: 2010-08-06 01:25:55 UTC
  • mfrom: (1688.1.3 drizzle)
  • Revision ID: brian@gaz-20100806012555-f1bxjm4iesdtiwlw
MergeĀ BuildĀ (rollup)

Show diffs side-by-side

added added

removed removed

Lines of Context:
81
81
 
82
82
extern size_t table_def_size;
83
83
static TableDefinitionCache table_def_cache;
84
 
static pthread_mutex_t LOCK_table_share;
85
 
bool table_def_inited= false;
86
84
 
87
85
/*****************************************************************************
88
86
  Functions to handle table definition cach (TableShare)
89
87
 *****************************************************************************/
90
88
 
91
89
 
 
90
// @todo switch this a boost::thread one only call.
92
91
void TableShare::cacheStart(void)
93
92
{
94
 
  pthread_mutex_init(&LOCK_table_share, MY_MUTEX_INIT_FAST);
95
 
  table_def_inited= true;
96
93
  /* 
97
94
   * This is going to overalloc a bit - as rehash sets the number of
98
95
   * buckets, not the number of elements. BUT, it'll allow us to not need
102
99
}
103
100
 
104
101
 
105
 
void TableShare::cacheStop(void)
106
 
{
107
 
  if (table_def_inited)
108
 
  {
109
 
    table_def_inited= false;
110
 
    pthread_mutex_destroy(&LOCK_table_share);
111
 
  }
112
 
}
113
 
 
114
 
 
115
102
/**
116
 
 * @TODO: This should return size_t
 
103
 * @TODO This should return size_t
117
104
 */
118
105
uint32_t cached_table_definitions(void)
119
106
{
186
173
  */
187
174
 
188
175
  /* We must do a lock to ensure that the structure is initialized */
189
 
  share->lock();
190
176
  if (share->error)
191
177
  {
192
178
    /* Table definition contained an error */
193
179
    share->open_table_error(share->error, share->open_errno, share->errarg);
194
 
    share->unlock();
195
180
 
196
181
    return NULL;
197
182
  }
198
183
 
199
184
  share->incrementTableCount();
200
 
  share->unlock();
201
185
 
202
186
  return share;
203
187
}