Free Electron
SegmentStore.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 #ifndef __data_SegmentStore_h__
8 #define __data_SegmentStore_h__
9 
10 namespace fe
11 {
12 
13 /** @brief Memory manager for state blocks.
14 
15  @ingroup data
16  */
17 class FE_DL_EXPORT SegmentStore : public StoreI, public ClassSafe<GlobalHolder>
18 {
19  public:
20  SegmentStore(void);
21 virtual ~SegmentStore(void);
22 virtual void *createSB(void);
23 virtual void *createSB(FE_UWORD count);
24 virtual hp<LayoutSB>& getLayout(void);
25 virtual void setLayout(sp<LayoutSB>& rspLayout);
26 virtual FE_UWORD skipSizeSB(void);
27 
28  /// Get the long name of this Store
29  const String verboseName(void) const;
30 
31  private:
32  friend class LayoutSB;
33 virtual void acquireSB(void *stateBlock);
34 virtual void releaseSB(const RecordSB &r_old);
35 virtual void freeSB(void *stateBlock);
36 
37  private:
38  void initSB(void *stateBlock);
39  void clear(void);
40  void* stateBlockOf(U32 index,void* pSegment);
41  FE_UWORD stateBlockBytes(void);
42  FE_UWORD segmentBytes(U32 count);
43  bool queryRC(void *sb, I32 *&pCount);
44 
45  class FreeHeader
46  {
47  public:
48  FreeHeader *m_pNext;
49  };
50  class Segment
51  {
52  public:
53  FE_UWORD m_allocated;
54  FE_UWORD m_used;
55  Segment *m_pNext;
56  };
57 
58  hp<LayoutSB> m_hpLayout;
59  Segment *m_pSegment;
60  FreeHeader *m_pFreeList;
61  //Accessor<I32> m_aRC;
62  TypeInfo m_i32TypeInfo;
63  FE_UWORD m_i32Index;
64  FE_UWORD m_cntIndex;
65 };
66 
67 inline const String SegmentStore::verboseName(void) const
68 {
69  return "SegmentStore " + name();
70 }
71 
72 
73 } /* namespace */
74 
75 #endif /* __data_SegmentStore_h__ */
76 
Class level locking for thread safety.
Definition: Safe.h:213
Memory manager for state blocks.
Definition: SegmentStore.h:17
kernel
Definition: namespace.dox:3
C++ type_info wrapper.
Definition: Type.h:20
Base class for state block memeory managers.
Definition: StoreI.h:31
Safe handle for shared pointer.
Definition: Handled.h:61
Automatically reference-counted string container.
Definition: String.h:128
Reference to an instance of a Layout.
Definition: RecordSB.h:35
const String verboseName(void) const
Get the long name of this Store.
Definition: SegmentStore.h:67
Intrusive Smart Pointer.
Definition: src/core/ptr.h:53
Record "type" definition.
Definition: LayoutSB.h:32