~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to storage/ndb/src/kernel/vm/DynArr256.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2003 MySQL AB
 
2
 
 
3
   This program is free software; you can redistribute it and/or modify
 
4
   it under the terms of the GNU General Public License as published by
 
5
   the Free Software Foundation; version 2 of the License.
 
6
 
 
7
   This program is distributed in the hope that it will be useful,
 
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
   GNU General Public License for more details.
 
11
 
 
12
   You should have received a copy of the GNU General Public License
 
13
   along with this program; if not, write to the Free Software
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
 
 
16
#ifndef DYNARR256_HPP
 
17
#define DYNARR256_HPP
 
18
 
 
19
#include "Pool.hpp"
 
20
 
 
21
class DynArr256;
 
22
struct DA256Page;
 
23
 
 
24
class DynArr256Pool
 
25
{
 
26
  friend class DynArr256;
 
27
public:
 
28
  DynArr256Pool();
 
29
  
 
30
  void init(Uint32 type_id, const Pool_context& pc);
 
31
  
 
32
protected:
 
33
  Uint32 m_type_id;
 
34
  Uint32 m_first_free;
 
35
  Pool_context m_ctx;
 
36
  struct DA256Page* m_memroot;
 
37
  
 
38
private:
 
39
  Uint32 seize();
 
40
  void release(Uint32);
 
41
};
 
42
 
 
43
class DynArr256
 
44
{
 
45
public:
 
46
  struct Head
 
47
  {
 
48
    Head() { m_ptr_i = RNIL; m_sz = 0;}
 
49
    
 
50
    Uint32 m_ptr_i;
 
51
    Uint32 m_sz;
 
52
 
 
53
    bool isEmpty() const { return m_sz == 0;}
 
54
  };
 
55
  
 
56
  DynArr256(DynArr256Pool & pool, Head& head) : 
 
57
    m_head(head), m_pool(pool){}
 
58
  
 
59
  Uint32* set(Uint32 pos);
 
60
  Uint32* get(Uint32 pos) const ;
 
61
  
 
62
  struct ReleaseIterator
 
63
  {
 
64
    Uint32 m_sz;
 
65
    Uint32 m_pos;
 
66
    Uint32 m_ptr_i[5];
 
67
  };
 
68
  
 
69
  void init(ReleaseIterator&);
 
70
  /**
 
71
   * return 0 - done
 
72
   *        1 - data (in retptr)
 
73
   *        2 - nodata
 
74
   */
 
75
  Uint32 release(ReleaseIterator&, Uint32* retptr);
 
76
protected:
 
77
  Head & m_head;
 
78
  DynArr256Pool & m_pool;
 
79
  
 
80
  bool expand(Uint32 pos);
 
81
  void handle_invalid_ptr(Uint32 pos, Uint32 ptrI, Uint32 p0);
 
82
};
 
83
 
 
84
#endif