Conversation
hearnadam
approved these changes
Mar 9, 2026
|
|
||
| object Unsafe: | ||
|
|
||
| def noop(using frame: Frame, allowUnsafe: AllowUnsafe): Unsafe = |
Collaborator
Author
There was a problem hiding this comment.
I made it a def to take the Frame and improve error messages but it doesn't seem worth it. I'll update
Comment on lines
+590
to
+592
| if parties == 0 then | ||
| // No parties remain, close gate | ||
| discard(this.close()) |
Collaborator
There was a problem hiding this comment.
We can skip handling the currentPromise since we expect close() to do so... Which is fine, because we only enter advancePass if we win the CAS.
| def join(n: Int)(using Frame): Unit < Sync = Sync.Unsafe.defer(self.join(n)) | ||
|
|
||
| /** Join the gate and apply an inline continuation, avoiding closure allocation. */ | ||
| inline def joinWith[B, S](inline f: => B < S)(using Frame): B < (S & Sync) = |
Collaborator
There was a problem hiding this comment.
Missing the joinN variant, but seems ok
| * | ||
| * Arrived in low bits means arrive is just `state + 1L` — no bit manipulation. Closed as sign bit means `closed` is just `state < 0`. | ||
| */ | ||
| private type State = State.Impl |
Collaborator
There was a problem hiding this comment.
Is this due to lack of opacity in the same file?
Collaborator
Author
There was a problem hiding this comment.
yep, it'd be nice if scala limited the visibility only to the companion
| private def doClose(g: Gate)(using Frame): Unit < Sync = | ||
| Sync.Unsafe.defer(discard(g.close())) // Scope cleanup, idempotent | ||
|
|
||
| /** Packed AtomicLong layout for Gate/Dynamic. |
Co-authored-by: Adam Hearn <22334119+hearnadam@users.noreply.github.com>
hearnadam
approved these changes
Mar 13, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I need an equivalent of Java's
Phaserfor a project. Instead of introducing a separate primitive, this PR replacesBarrierwithGate, and the features ofPhaserare a new typeGate.Dynamic. I find java's naming for these abstractions too opaque so I decided to go with a new one that provides a better mental model.