Zero  0.1.0
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
ConsolidationArray Class Reference

The implementation class of Consolidation Array. More...

#include <log_carray.h>

Public Types

enum  Constants {
  ALL_SLOT_COUNT = 256, DEFAULT_ACTIVE_SLOT_COUNT = 3, SLOT_AVAILABLE = 0, SLOT_UNUSED = -1,
  SLOT_PENDING = -2, SLOT_FINISHED = -4
}
 

Public Member Functions

 ConsolidationArray (int active_slot_count)
 
 ~ConsolidationArray ()
 
CArraySlotjoin_slot (int32_t size, carray_status_t &status)
 
void join_expose (CArraySlot *slot)
 
CArraySlotgrab_delegated_expose (CArraySlot *slot)
 
void wait_for_leader (CArraySlot *slot)
 
bool wait_for_expose (CArraySlot *slot)
 
void replace_active_slot (CArraySlot *slot)
 

Static Public Member Functions

static carray_status_t join_carray_status (carray_status_t current_status, int32_t size)
 
static int32_t extract_carray_log_size (carray_status_t current_status)
 

Private Member Functions

int _indexof (const CArraySlot *slot) const
 

Private Attributes

int32_t _slot_mark
 
const int32_t _active_slot_count
 
CArraySlot _all_slots [ALL_SLOT_COUNT]
 
CArraySlot ** _active_slots
 
mcs_lock _expose_lock
 Lock to protect threads releasing their log buffer. More...
 

Detailed Description

The implementation class of Consolidation Array.

See Section A.2 and A.3 of Aether paper.

Member Enumeration Documentation

§ Constants

Constant numbers.

Enumerator
ALL_SLOT_COUNT 

Total number of slots.

DEFAULT_ACTIVE_SLOT_COUNT 

Default value for max number of slots that can be active at the same time.

SLOT_AVAILABLE 

slots that are in active slots and up for grab have this carray_status_t.

SLOT_UNUSED 

slots that are in the pool but not in active slots have this carray_status_t.

SLOT_PENDING 

Once the first thread in the slot puts this as carray_status_t, other threads can no longer join the slot.

SLOT_FINISHED 

Once the first thread acquires a buffer space and LSN, it puts this MINUS the combined log size as the carray_status_t. All threads in the slot atomically add its log size to this, making the last one notice that it is exactly SLOT_FINISHED.

Constructor & Destructor Documentation

§ ConsolidationArray()

ConsolidationArray::ConsolidationArray ( int  active_slot_count)
Parameters
[in]active_slot_countMax number of slots that can be active at the same time

§ ~ConsolidationArray()

ConsolidationArray::~ConsolidationArray ( )

Member Function Documentation

§ _indexof()

int ConsolidationArray::_indexof ( const CArraySlot slot) const
inlineprivate

§ extract_carray_log_size()

static int32_t ConsolidationArray::extract_carray_log_size ( carray_status_t  current_status)
inlinestatic

Extract the current-total of log size in C-Array status.

§ grab_delegated_expose()

CArraySlot * ConsolidationArray::grab_delegated_expose ( CArraySlot slot)

Atomically checks if the slot has a successor slot that delegated its release to this slot, returning the "next" slot to expose. No matter whether there is "next", this slot is atomically freed from the expose chain. See Section A.3 of Aether paper.

Returns
NULL if no one delegated, a delegated slot otherwise.

§ join_carray_status()

static carray_status_t ConsolidationArray::join_carray_status ( carray_status_t  current_status,
int32_t  size 
)
inlinestatic

Calculate a new CArray status after joining the given log size to the existing status.

§ join_expose()

void ConsolidationArray::join_expose ( CArraySlot slot)

join the memcpy-complete queue but don't spin yet. This sets the CArraySlot::me2 and CArraySlot::pred2.

§ join_slot()

CArraySlot * ConsolidationArray::join_slot ( int32_t  size,
carray_status_t status 
)

Grabs some active slot and atomically joins the slot.

Parameters
[in]sizelog size to add
[out]statusatomically obtained status of the joined slot
Returns
the slot we have just joined

§ replace_active_slot()

void ConsolidationArray::replace_active_slot ( CArraySlot slot)

Retire the given slot from active slot, upgrading an unused thread to an active slot.

Parameters

§ wait_for_expose()

bool ConsolidationArray::wait_for_expose ( CArraySlot slot)

Tries to delegate the buffer release of this slot to slowly-moving predecessor if there is.

Returns
true if we successfully delegated our dirty work to the poor predecessor.
Precondition
current thread is the leader of the slot

§ wait_for_leader()

void ConsolidationArray::wait_for_leader ( CArraySlot slot)

Spins until the leader of the given slot acquires log buffer.

Precondition
current thread is not the leader of the slot

Member Data Documentation

§ _active_slot_count

const int32_t ConsolidationArray::_active_slot_count
private

Max number of slots that can be active at the same time.

§ _active_slots

CArraySlot** ConsolidationArray::_active_slots
private

Active slots that are (probably) up for grab or join.

§ _all_slots

CArraySlot ConsolidationArray::_all_slots[ALL_SLOT_COUNT]
private

All slots, including available, currently used, or retired slots.

§ _expose_lock

mcs_lock ConsolidationArray::_expose_lock
private

Lock to protect threads releasing their log buffer.

§ _slot_mark

int32_t ConsolidationArray::_slot_mark
private

Clockhand of active slots. We use this to evenly distribute accesses to slots. This value is not protected at all because we don't care even if it's not perfectly even. We anyway atomically obtain the slot.


The documentation for this class was generated from the following files: