~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/information_engine/information_share.h

Updating Padraig's work for I_S

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include <string>
24
24
 
25
25
/*
26
 
  Shared class for correct LOCK operation
27
 
  TODO -> Fix to never remove/etc. We could generate all of these in startup if we wanted to.
28
 
  Tracking count? I'm not sure that is needed at all. We could possibly make this a member of
29
 
  engine as well (should we just hide the share detail?)
30
26
*/
31
27
 
32
 
class InformationCursor;
33
 
 
34
28
class InformationShare 
35
29
{
 
30
private:
36
31
  uint32_t count;
37
 
  std::string name;
38
 
  drizzled::plugin::InfoSchemaTable *i_s_table;
 
32
  drizzled::plugin::InfoSchemaTable *table;
 
33
  THR_LOCK lock;
 
34
 
39
35
 
40
36
public:
41
37
 
42
 
  InformationShare(const char *arg) :
43
 
    count(1),
44
 
    name(arg),
45
 
    i_s_table(NULL)
 
38
  InformationShare(const std::string &in_name) :
 
39
    count(1)
46
40
  {
47
41
    thr_lock_init(&lock);
48
 
  };
 
42
    table= drizzled::plugin::InfoSchemaTable::getTable(in_name.c_str());
 
43
  }
49
44
 
50
45
  ~InformationShare() 
51
46
  {
52
47
    thr_lock_delete(&lock);
53
48
  }
54
49
 
55
 
  void inc(void) { count++; }
56
 
  uint32_t dec(void) { return --count; }
57
 
 
58
 
  void setInfoSchemaTable(const std::string &in_name)
59
 
  {
60
 
    i_s_table= drizzled::plugin::InfoSchemaTable::getTable(in_name.c_str());
61
 
  }
62
 
 
 
50
  /**
 
51
   * Increment the counter which tracks how many instances of this share are
 
52
   * currently open.
 
53
   * @return the new counter value
 
54
   */
 
55
  uint32_t incUseCount(void) 
 
56
  { 
 
57
    return ++count; 
 
58
  }
 
59
 
 
60
  /**
 
61
   * Decrement the count which tracks how many instances of this share are
 
62
   * currently open.
 
63
   * @return the new counter value
 
64
   */
 
65
  uint32_t decUseCount(void) 
 
66
  { 
 
67
    return --count; 
 
68
  }
 
69
 
 
70
  /**
 
71
   * @ return the value of the use counter for this share
 
72
   */
 
73
  uint32_t getUseCount() const
 
74
  {
 
75
    return count;
 
76
  }
 
77
 
 
78
  /**
 
79
   * @return the table name associated with this share.
 
80
   */
 
81
  const std::string &getName() const
 
82
  {
 
83
    return table->getTableName();
 
84
  }
 
85
 
 
86
  /**
 
87
   * @return the I_S table associated with this share.
 
88
   */
63
89
  drizzled::plugin::InfoSchemaTable *getInfoSchemaTable()
64
90
  {
65
 
    return i_s_table;
 
91
    return table;
66
92
  }
67
93
 
68
 
  static InformationShare *get(const char *table_name);
69
 
  static void free(InformationShare *share);
70
 
  static void start(void);
71
 
  static void stop(void);
72
 
  THR_LOCK lock;
 
94
  /**
 
95
   * @return the thread lock for this share.
 
96
   */
 
97
  THR_LOCK *getThreadLock()
 
98
  {
 
99
    return &lock;
 
100
  }
73
101
};
74
102
 
75
103
#endif /* PLUGIN_INFORMATION_ENGINE_INFORMATION_SHARE_H */