-
Notifications
You must be signed in to change notification settings - Fork 506
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
Conversation
|
||
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 |
There was a problem hiding this comment.
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] |
There was a problem hiding this comment.
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.
There was a problem hiding this 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
This is a small internal refactoring of the "new"
Dispatcher
.Currently during cancellation there is a racy write/read of
action
(a plainvar
), and this is resolved by spinning onstateR
(anAtomicReference
). The idea of this PR is that since we already have anAtomicReference
, which we're reading anyway, we can avoid the data race, and thus the spinning, by puttingaction
inside theAtomicReference
.Besides this, there are 2 very small changes: removing an outdated comment, and an unnecessary type parameter.