-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
making workqueue push_-/pop_task lock-free
Summary: This is relatively straightforward change that makes the `push_task` and `pop_task` operations lock-free. To achieve this, we split the `m_queue_mtx` protected `m_queue` into two parts: - A vector of initial tasks, `m_initial_tasks`. This is drained by atomically incrementing a `m_next_initial_task` counter, until we hit the (immutable) `m_initial_tasks.size()`. - A linked list of additionally pushed tasks, `m_additional_tasks`. This is mutated via atomic `compare_exchange` operations. A little complication is that we can't eagerly destroy popped nodes, as racing pop-operations might reference them, so we maintain another linked list of erased node that eventually get destroyed in the destructor. This is a behavior-preserving change. Reviewed By: yuxuanchen1997 Differential Revision: D50952675 fbshipit-source-id: 4d438b295b117ea8c78d700c3a3f943dbda6736b
- Loading branch information
1 parent
1169daf
commit 036aca0
Showing
2 changed files
with
115 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters