Zero  0.1.0
Public Member Functions | Public Attributes | List of all members
GcGeneration< T > Struct Template Reference

A generation of objects. More...

#include <w_gc_pool_forest.h>

Public Member Functions

 GcGeneration (uint32_t generation_nowrap_arg)
 
 ~GcGeneration ()
 
uint32_t get_free_count () const
 
bool preallocate_segments (size_t segment_count, gc_offset segment_size)
 
void recycle (uint32_t generation_nowrap_arg)
 

Public Attributes

bool retire_suggested
 
uint32_t total_segments
 
uint32_t allocated_segments
 
uint32_t generation_nowrap
 
GcSegment< T > * segments [GC_MAX_SEGMENTS]
 

Detailed Description

template<class T>
struct GcGeneration< T >

A generation of objects.

A generation groups objects in similar age and controls when we can start deallocating segments in it.

Constructor & Destructor Documentation

§ GcGeneration()

template<class T>
GcGeneration< T >::GcGeneration ( uint32_t  generation_nowrap_arg)
inline

§ ~GcGeneration()

template<class T>
GcGeneration< T >::~GcGeneration ( )
inline

Member Function Documentation

§ get_free_count()

template<class T>
uint32_t GcGeneration< T >::get_free_count ( ) const
inline

Returns the number of segments up for grab.

§ preallocate_segments()

template<class T >
bool GcGeneration< T >::preallocate_segments ( size_t  segment_count,
gc_offset  segment_size 
)
inline

Pre-allocate a few segments and make them up for grab.

Parameters
[in]segment_countHow many segments we should reserve now
[in]segment_sizeHow many objects we should allocate per segment
Returns
whether we preallocated the segments. false if the generation is already full.

§ recycle()

template<class T>
void GcGeneration< T >::recycle ( uint32_t  generation_nowrap_arg)
inline

Recycle this generation assuming there is no transaction that uses any of the segments in this generation. If the assumption does not hold, this might cause ABA and other corruption.

Member Data Documentation

§ allocated_segments

template<class T>
uint32_t GcGeneration< T >::allocated_segments

Number of allocated segments owned by some thread. If allocated_segments < total_segments, there are some segments other threads can try occupying. We don't allow "holes" in segment allocation, so this monotonically increases. We use atomic operation to increase this (=occupy the segment). 32bits for CAS.

§ generation_nowrap

template<class T>
uint32_t GcGeneration< T >::generation_nowrap

ID of this generation.

§ retire_suggested

template<class T>
bool GcGeneration< T >::retire_suggested

A loose request for threads to start retiring this generation. Threads that saw this stop making a new segment in this generation. It's loose. Threads might not take barriers to check this.

§ segments

template<class T>
GcSegment<T>* GcGeneration< T >::segments[GC_MAX_SEGMENTS]

Active segments in this generation. The first total_segments elements are non-NULL.

§ total_segments

template<class T>
uint32_t GcGeneration< T >::total_segments

Number of total segments. We don't reuse segments, so this monotonically increases. We use atomic operation to increase this. 32bits for CAS.


The documentation for this struct was generated from the following file: