zephyr::raw

Function k_work_cancel_sync

source
pub unsafe extern "C" fn k_work_cancel_sync(
    work: *mut k_work,
    sync: *mut k_work_sync,
) -> bool
Expand description

@brief Cancel a work item and wait for it to complete.

Same as k_work_cancel() but does not return until cancellation is complete. This can be invoked by a thread after k_work_cancel() to synchronize with a previous cancellation.

On return the work structure will be idle unless something submits it after the cancellation was complete.

@note Be careful of caller and work queue thread relative priority. If this function sleeps it will not return until the work queue thread completes the tasks that allow this thread to resume.

@note Behavior is undefined if this function is invoked on @p work from a work queue running @p work.

@param work pointer to the work item.

@param sync pointer to an opaque item containing state related to the pending cancellation. The object must persist until the call returns, and be accessible from both the caller thread and the work queue thread. The object must not be used for any other flush or cancel operation until this one completes. On architectures with CONFIG_KERNEL_COHERENCE the object must be allocated in coherent memory.

@retval true if work was pending (call had to wait for cancellation of a running handler to complete, or scheduled or submitted operations were cancelled); @retval false otherwise