~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/lock.h

  • Committer: Brian Aker
  • Date: 2010-10-28 17:12:01 UTC
  • mfrom: (1887.1.3 merge)
  • Revision ID: brian@tangent.org-20101028171201-baj6l1bnntn1s4ad
Merge in POTFILES changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
22
22
 
23
23
#include <vector>
24
24
#include "drizzled/thr_lock.h"
25
 
#include "drizzled/locking/global.h"
26
25
 
27
26
namespace drizzled
28
27
{
33
32
 
34
33
class DrizzleLock
35
34
{
 
35
  std::vector<Table *> table;
 
36
  std::vector<THR_LOCK_DATA *> locks;
36
37
public:
 
38
  uint32_t table_count;
 
39
  uint32_t lock_count;
 
40
 
37
41
  Table **getTable()
38
42
  {
39
43
    return &table[0];
44
48
    return &locks[0];
45
49
  }
46
50
 
47
 
  size_t sizeTable() const
48
 
  {
49
 
    return table.size();
50
 
  }
51
 
 
52
 
  void resizeTable(size_t arg)
53
 
  {
54
 
    table.resize(arg);
55
 
  }
56
 
 
57
 
  size_t sizeLock() const
 
51
  size_t sizeLock()
58
52
  {
59
53
    return lock_count;
60
54
  }
61
55
 
 
56
  size_t sizeTable()
 
57
  {
 
58
    return table_count;
 
59
  }
 
60
 
62
61
  void resetLock()
63
62
  {
64
63
    lock_count= 0;
69
68
    lock_count= arg;
70
69
  }
71
70
 
 
71
  void setTable(size_t arg)
 
72
  {
 
73
    table_count= arg;
 
74
  }
 
75
 
72
76
  void reset(void);
73
77
  void unlock(uint32_t count);
74
78
 
75
 
  DrizzleLock(size_t table_count_arg)
 
79
  DrizzleLock(size_t table_count_arg, size_t lock_count_arg) :
 
80
    table_count(table_count_arg),
 
81
    lock_count(lock_count_arg)
76
82
  {
77
 
    table.resize(table_count_arg);
78
 
    lock_count= table_count_arg * 2;
 
83
    table.resize(table_count);
79
84
    locks.resize(lock_count);
80
85
  }
81
86
 
82
 
private:
83
 
  uint32_t lock_count;
84
 
 
85
 
  std::vector<Table *> table;
86
 
  std::vector<THR_LOCK_DATA *> locks;
87
 
  std::vector<THR_LOCK_DATA *> copy_of;
88
87
};
89
88
 
90
 
/* lockTables() and open_table() flags bits */
 
89
DrizzleLock *mysql_lock_tables(Session *session, Table **table, uint32_t count,
 
90
                               uint32_t flags, bool *need_reopen);
 
91
/* mysql_lock_tables() and open_table() flags bits */
91
92
#define DRIZZLE_LOCK_IGNORE_GLOBAL_READ_LOCK      0x0001
92
93
#define DRIZZLE_LOCK_IGNORE_FLUSH                 0x0002
93
94
#define DRIZZLE_LOCK_NOTIFY_IF_NEED_REOPEN        0x0004
94
95
#define DRIZZLE_OPEN_TEMPORARY_ONLY               0x0008
95
96
 
 
97
void mysql_unlock_tables(Session *session, DrizzleLock *sql_lock);
 
98
void mysql_unlock_read_tables(Session *session, DrizzleLock *sql_lock);
 
99
void mysql_unlock_some_tables(Session *session, Table **table, uint32_t count);
 
100
void mysql_lock_remove(Session *session, Table *table);
 
101
void mysql_lock_abort(Session *session, Table *table);
 
102
bool mysql_lock_abort_for_thread(Session *session, Table *table);
 
103
bool lock_global_read_lock(Session *session);
 
104
void unlock_global_read_lock(Session *session);
 
105
bool wait_if_global_read_lock(Session *session, bool abort_on_refresh,
 
106
                              bool is_not_commit);
 
107
void start_waiting_global_read_lock(Session *session);
 
108
bool make_global_read_lock_block_commit(Session *session);
 
109
void broadcast_refresh(void);
 
110
 
 
111
/* Lock based on name */
 
112
void unlock_table_name(TableList *table_list);
 
113
void unlock_table_names(TableList *table_list, TableList *last_table);
 
114
bool lock_table_names_exclusively(Session *session, TableList *table_list);
 
115
 
96
116
} /* namespace drizzled */
97
117
 
98
118
#endif /* DRIZZLED_LOCK_H */