MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LockQueue.hpp
1 /*
2  Copyright (C) 2007, 2008 MySQL AB
3  All rights reserved. Use is subject to license terms.
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; version 2 of the License.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 #ifndef BLOCK_MUTEX_IMPL_HPP
20 #define BLOCK_MUTEX_IMPL_HPP
21 
22 #include "ArrayPool.hpp"
23 #include "DLFifoList.hpp"
24 #include "KeyTable.hpp"
25 #include <signaldata/UtilLock.hpp>
26 
27 class LockQueue
28 {
29 public:
30  LockQueue() {}
31 
36  {
37  LockQueueElement() {}
38 
39  UtilLockReq m_req;
40  union {
41  Uint32 nextPool;
42  Uint32 nextList;
43  };
44  Uint32 prevList;
45  };
46 
48 
49  Uint32 lock(SimulatedBlock*,
50  Pool&, const UtilLockReq*, const UtilLockReq** = 0);
51  Uint32 unlock(SimulatedBlock*,
52  Pool&, const UtilUnlockReq* req);
53 
57  struct Iterator
58  {
59  SimulatedBlock* m_block;
60  Pool * thePool;
61  Ptr<LockQueueElement> m_prev;
62  Ptr<LockQueueElement> m_curr;
63  };
64 
65  bool first(SimulatedBlock*, Pool& pool, Iterator&);
66  bool next(Iterator&);
67 
73  int checkLockGrant(Iterator &, UtilLockReq * req);
74 
78  void clear (Pool&);
79 
84 
85 private:
90 };
91 
92 #endif