Skip to main content

splinter_shard_claim

Function splinter_shard_claim 

Source
pub unsafe extern "C" fn splinter_shard_claim(
    shard_id: u32,
    intent: u8,
    priority: u8,
    duration_tsc: u64,
) -> c_int
Expand description

@brief Claim a shard bid slot and declare memory intent.

CAS-claims the first empty slot (or refreshes the caller’s existing slot if shard_id already owns one), stamping pid=getpid() and claimed_at=splinter_now().

@param shard_id Caller-chosen non-zero shard identifier (unique per process). @param intent splinter_intent_t advisement class. @param priority 0-255, higher wins elections. @param duration_tsc Declared sovereignty window in splinter_now() ticks. @return 0 on success, -1 if the table is full (errno=ENOSPC), -2 on bad args / no store / shard_id==0.

@note On a fresh claim the descriptive fields are published with memory_order_release after the shard_id CAS makes the slot visible. A racing election that observes the new shard_id but not-yet-stored fields treats the bid as SPL_INTENT_NONE / priority 0 for at most one election; the next election corrects it. Advisement is a hint, so this is acceptable by design.