~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table/cache.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:
19
19
 */
20
20
 
21
21
#include <config.h>
 
22
#include <drizzled/table/cache.h>
22
23
 
23
24
#include <sys/types.h>
24
25
#include <sys/stat.h>
25
26
#include <fcntl.h>
26
27
 
27
 
#include <drizzled/identifier.h>
28
 
#include <drizzled/table.h>
29
 
#include <drizzled/session.h>
30
 
#include <drizzled/sql_base.h>
31
 
#include <drizzled/table/concurrent.h>
32
 
#include <drizzled/table/cache.h>
33
 
#include <drizzled/table/unused.h>
34
 
#include <drizzled/pthread_globals.h>
35
 
#include <drizzled/sys_var.h>
36
 
#include <drizzled/open_tables_state.h>
 
28
#include <drizzled/identifier.h>
 
29
#include <drizzled/open_tables_state.h>
 
30
#include <drizzled/pthread_globals.h>
 
31
#include <drizzled/session.h>
 
32
#include <drizzled/sql_base.h>
 
33
#include <drizzled/sys_var.h>
 
34
#include <drizzled/table.h>
 
35
#include <drizzled/table/concurrent.h>
 
36
#include <drizzled/table/unused.h>
37
37
 
38
38
namespace drizzled {
39
39
namespace table {
43
43
 
44
44
CacheMap& getCache()
45
45
{
46
 
  return Cache::singleton().getCache();
 
46
  return Cache::getCache();
47
47
}
48
48
 
49
49
/*
54
54
  entry         Table to remove
55
55
 
56
56
  NOTE
57
 
  We need to have a lock on table::Cache::singleton().mutex() when calling this
 
57
  We need to have a lock on table::Cache::mutex() when calling this
58
58
*/
59
59
 
60
60
static void free_cache_entry(table::Concurrent *table)
162
162
  close_thread_tables() is called.
163
163
 
164
164
  PREREQUISITES
165
 
  Lock on table::Cache::singleton().mutex()()
 
165
  Lock on table::Cache::mutex()()
166
166
 
167
167
  RETURN
168
168
  0  This thread now have exclusive access to this table and no other thread
209
209
        /*
210
210
          Now we must abort all tables locks used by this thread
211
211
          as the thread may be waiting to get a lock for another table.
212
 
          Note that we need to hold table::Cache::singleton().mutex() while going through the
 
212
          Note that we need to hold table::Cache::mutex() while going through the
213
213
          list. So that the other thread cannot change it. The other
214
 
          thread must also hold table::Cache::singleton().mutex() whenever changing the
 
214
          thread must also hold table::Cache::mutex() whenever changing the
215
215
          open_tables list. Aborting the MERGE lock after a child was
216
216
          closed and before the parent is closed would be fatal.
217
217
        */
247
247
        dropping_tables++;
248
248
        if (likely(signalled))
249
249
        {
250
 
          boost_unique_lock_t scoped(table::Cache::singleton().mutex(), boost::adopt_lock_t());
 
250
          boost::mutex::scoped_lock scoped(table::Cache::mutex(), boost::adopt_lock_t());
251
251
          COND_refresh.wait(scoped);
252
252
          scoped.release();
253
253
        }
261
261
            ensure that the thread actually hears our signal
262
262
            before we go to sleep. Thus we wait for a short time
263
263
            and then we retry another loop in the
264
 
            table::Cache::singleton().removeTable routine.
 
264
            table::Cache::removeTable routine.
265
265
          */
266
266
          boost::xtime xt;
267
267
          xtime_get(&xt, boost::TIME_UTC);
268
268
          xt.sec += 10;
269
 
          boost_unique_lock_t scoped(table::Cache::singleton().mutex(), boost::adopt_lock_t());
 
269
          boost::mutex::scoped_lock scoped(table::Cache::mutex(), boost::adopt_lock_t());
270
270
          COND_refresh.timed_wait(scoped, xt);
271
271
          scoped.release();
272
272
        }