MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TimeQueue.hpp
1 /*
2  Copyright (C) 2003, 2005, 2006 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 TimeQueue_H
20 #define TimeQueue_H
21 
22 #include <kernel_types.h>
23 #include "Prio.hpp"
24 
25 #define MAX_NO_OF_SHORT_TQ 512
26 #define MAX_NO_OF_LONG_TQ 512
27 #define MAX_NO_OF_TQ (MAX_NO_OF_SHORT_TQ + MAX_NO_OF_LONG_TQ)
28 #define NULL_TQ_ENTRY 65535
29 
30 class Signal;
31 
32 struct TimeStruct
33 {
34  Uint16 delay_time;
35  Uint16 job_index;
36 };
37 
39 {
40  struct TimeStruct time_struct;
41  Uint32 copy_struct;
42 };
43 
44 class TimeQueue
45 {
46 public:
47  TimeQueue();
48  ~TimeQueue();
49 
50  void insert(Signal* signal, BlockNumber bnr,
51  GlobalSignalNumber gsn, Uint32 delayTime);
52  void clear();
53  void scanTable(); // Called once per millisecond
54  Uint32 getIndex();
55  void releaseIndex(Uint32 aIndex);
56  void recount_timers();
57 
58 private:
59  TimerEntry theShortQueue[MAX_NO_OF_SHORT_TQ];
60  TimerEntry theLongQueue[MAX_NO_OF_LONG_TQ];
61  Uint16 theFreeIndex[MAX_NO_OF_TQ];
62 };
63 
64 #endif