Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simplify the implement of mark_sleep and mark_woken #68

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

glorv
Copy link
Contributor

@glorv glorv commented Aug 16, 2022

No description provided.

@@ -103,38 +103,22 @@ impl<T> QueueCore<T> {
///
/// It can be marked as sleep only when the pool is not shutting down.
pub fn mark_sleep(&self) -> bool {
let mut cnt = self.active_workers.load(Ordering::SeqCst);
loop {
if is_shutdown(cnt) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, the active count should be not important once the pool is shut down.

@BusyJay Is there any special reason to check shutdown first?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. Combining a loop and compare_exchange_weak just to be more performant when there is something to check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants