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

Dispatcher: avoid spinning #4052

Merged
merged 4 commits into from
May 25, 2024
Merged

Conversation

durban
Copy link
Contributor

@durban durban commented Apr 16, 2024

This is a small internal refactoring of the "new" Dispatcher.

Currently during cancellation there is a racy write/read of action (a plain var), and this is resolved by spinning on stateR (an AtomicReference). The idea of this PR is that since we already have an AtomicReference, which we're reading anyway, we can avoid the data race, and thus the spinning, by putting action inside the AtomicReference.

Besides this, there are 2 very small changes: removing an outdated comment, and an unnecessary type parameter.


final case class Finalizer[F[_]](action: F[Unit]) extends Registration[F]

final case class PoisonPill[F[_]]() extends Registration[F]
}

// the signal is just a skolem for the atomic references; we never actually run it
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This comment probably referred to an older version of the code(?).

final case class Running[F[_]](cancel: F[Unit]) extends RegState[F]
final case class CancelRequested[F[_]](latch: Promise[Unit]) extends RegState[F]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unrelated, but this type param seems unnecessary.

@durban durban requested a review from djspiewak April 16, 2024 22:33
Copy link
Member

@djspiewak djspiewak left a comment

Choose a reason for hiding this comment

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

This is a really nice simplification

@djspiewak djspiewak merged commit 636ab77 into typelevel:series/3.5.x May 25, 2024
28 of 31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants