|
Zero
0.1.0
|
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 () | |
| CArraySlot * | join_slot (int32_t size, carray_status_t &status) |
| void | join_expose (CArraySlot *slot) |
| CArraySlot * | grab_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... | |
The implementation class of Consolidation Array.
See Section A.2 and A.3 of Aether paper.
Constant numbers.
| ConsolidationArray::ConsolidationArray | ( | int | active_slot_count | ) |
| [in] | active_slot_count | Max number of slots that can be active at the same time |
| ConsolidationArray::~ConsolidationArray | ( | ) |
|
inlineprivate |
|
inlinestatic |
Extract the current-total of log size in C-Array status.
| 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.
|
inlinestatic |
Calculate a new CArray status after joining the given log size to the existing status.
| void ConsolidationArray::join_expose | ( | CArraySlot * | slot | ) |
join the memcpy-complete queue but don't spin yet. This sets the CArraySlot::me2 and CArraySlot::pred2.
| CArraySlot * ConsolidationArray::join_slot | ( | int32_t | size, |
| carray_status_t & | status | ||
| ) |
Grabs some active slot and atomically joins the slot.
| [in] | size | log size to add |
| [out] | status | atomically obtained status of the joined slot |
| void ConsolidationArray::replace_active_slot | ( | CArraySlot * | slot | ) |
Retire the given slot from active slot, upgrading an unused thread to an active slot.
| bool ConsolidationArray::wait_for_expose | ( | CArraySlot * | slot | ) |
Tries to delegate the buffer release of this slot to slowly-moving predecessor if there is.
| void ConsolidationArray::wait_for_leader | ( | CArraySlot * | slot | ) |
Spins until the leader of the given slot acquires log buffer.
|
private |
Max number of slots that can be active at the same time.
|
private |
Active slots that are (probably) up for grab or join.
|
private |
All slots, including available, currently used, or retired slots.
|
private |
Lock to protect threads releasing their log buffer.
|
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.
1.8.12