X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=urcu%2Fworkqueue-fifo.h;h=c2766e5ac85f7c696bc507e996ab5fa94fa3d220;hb=2e1ced1f1ec38b5c9e85fe407a6e8390b9ac6416;hp=458d97663ff599b3163c797c7b239cfc79dcdf07;hpb=2f02be5c694af89378293d463aa5fd2c2ccd3848;p=urcu.git diff --git a/urcu/workqueue-fifo.h b/urcu/workqueue-fifo.h index 458d976..c2766e5 100644 --- a/urcu/workqueue-fifo.h +++ b/urcu/workqueue-fifo.h @@ -502,4 +502,31 @@ void urcu_workqueue_shutdown(struct urcu_workqueue *queue) __urcu_workqueue_wakeup_all(queue); } +/* + * Use to let dispatcher steal work from the entire queue in case of + * stall. The "worker" parameter need to be intialized, but is usually + * not registered. + */ +static inline +bool urcu_workqueue_steal_all(struct urcu_workqueue *queue, + struct urcu_worker *worker) +{ + struct urcu_worker *sibling; + bool has_work = false; + + if (worker->flags & URCU_WORKER_STEAL) { + rcu_read_lock(); + /* Steal from each worker */ + cds_list_for_each_entry_rcu(sibling, &queue->sibling_head, + sibling_node) + has_work |= ___urcu_grab_work(worker, &sibling->head, + &sibling->tail, 1); + rcu_read_unlock(); + } + + /* Steal from global workqueue */ + has_work |= ___urcu_grab_work(worker, &queue->head, &queue->tail, 0); + return has_work; +} + #endif /* _URCU_WORKQUEUE_FIFO_H */