Task Operations

void lace_barrier(void)

Collective barrier across all workers.

All workers must reach this call before any of them returns from it. Must be called from inside a Lace task.

Warning

Deadlock will occur if not all workers reach the lace_barrier().

void lace_drop(lace_worker *lw)

Drop the last spawned task without retrieving its result.

If the task has not been stolen, it is cancelled. If it has already been stolen, the thief will complete it but the result is discarded. Must follow LIFO order relative to other SPAWN/SYNC/DROP calls.

Parameters:

lw – Pointer to the current worker

static inline int lace_is_stolen_task(lace_task *t)

Check whether a task has been stolen by another worker.

Parameters:

t – Pointer to a task (as returned by NAME_SPAWN)

Returns:

1 if stolen, 0 otherwise

static inline int lace_is_completed_task(lace_task *t)

Check whether a task has been completed.

Parameters:

t – Pointer to a task (as returned by NAME_SPAWN)

Returns:

1 if completed, 0 otherwise

static inline void *lace_task_result(lace_task *t)

Retrieve a pointer to the result storage inside a completed task.

The result is available after lace_is_completed_task() returns 1.

Parameters:

t – Pointer to a completed lace_task

void lace_steal_random(lace_worker *lw)

Attempt to steal and execute a random task from another worker.

This is a low-level function for the uncommon case where a task needs to block on an external condition and wants to keep its worker productive. In normal fork-join code the framework handles work distribution through SYNC automatically.

Parameters:

lw – Pointer to the current worker

static inline void lace_check_yield(lace_worker *lw)

Check for pending NEWFRAME/TOGETHER interruptions and yield if needed.

Call periodically from long-running tasks to cooperate with interruptions (e.g. stop-the-world garbage collection).

Parameters:

lw – Pointer to the current worker

static inline void lace_make_all_shared(void)

Make all tasks on the current worker’s deque stealable.

Normally only tasks up to the split point are visible to thieves. This moves the split to the head, exposing all pending tasks.

static inline lace_task *lace_get_head(void)

Get the current head pointer of the calling worker’s deque.

Returns:

Pointer to the task at the head of the deque