Skip to content

InputMultispan and OutputMultispan + basic adoption in RigidArray and UniqueArray#579

Open
Catfish-Man wants to merge 22 commits intoapple:mainfrom
Catfish-Man:leeloo-dallas-multispan
Open

InputMultispan and OutputMultispan + basic adoption in RigidArray and UniqueArray#579
Catfish-Man wants to merge 22 commits intoapple:mainfrom
Catfish-Man:leeloo-dallas-multispan

Conversation

@Catfish-Man
Copy link
Member

@Catfish-Man Catfish-Man commented Feb 24, 2026

This gets us the core "asynchronously create a unique/rigid array with a multi output span"

@safe
@frozen
@available(SwiftStdlib 5.0, *)
public struct OutputMultispan<Element: ~Copyable>: ~Copyable, ~Escapable {
Copy link
Member

Choose a reason for hiding this comment

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

Would be interesting to see if we could add a conversion method that vends you an io_vec from this safely

Copy link
Member Author

Choose a reason for hiding this comment

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

ooh that would be nice

@Catfish-Man Catfish-Man changed the title WIP OutputMultispan + basic adoption in RigidArray and UniqueArray WIP InputMultispan and OutputMultispan + basic adoption in RigidArray and UniqueArray Feb 26, 2026
#endif

@available(SwiftStdlib 5.0, *)
extension RigidArray where Element: ~Copyable {
Copy link
Member

Choose a reason for hiding this comment

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

I'm surprised this works -- BasicContainers imports ContainersPreview, not the other way round. I expect this will need to get moved to BasicContainers.

@Catfish-Man Catfish-Man changed the title WIP InputMultispan and OutputMultispan + basic adoption in RigidArray and UniqueArray InputMultispan and OutputMultispan + basic adoption in RigidArray and UniqueArray Mar 11, 2026
@Catfish-Man Catfish-Man marked this pull request as ready for review March 13, 2026 20:50
@Catfish-Man
Copy link
Member Author

I'll take a look at any CI failures, the tests pass locally so they're probably just forgetting to update one of the other build systems


// Shift elements after the subrange if necessary
let shiftDistance = addedCount
if shiftDistance != 0 && subrange.upperBound < count {
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like this code accounts for the possibility of multiple inline elements, but line 145 above assumes the presence of only a single inline element. Should they be made consistent?

Copy link
Member Author

Choose a reason for hiding this comment

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

I really want to generalize the rest of it to support multiple inline elements, but I haven't decided how practical that is. Picking one option definitely seems good though.

@inlinable
public init<E: Error>(
capacity: Int,
initializingWith body: @escaping (inout OutputMultispan<Element>) async throws(E) -> Void
Copy link
Member Author

Choose a reason for hiding this comment

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

This can run into ambiguity issues when used with the trailing closure syntax. I should figure out what to do about that, because we don't want to penalize the more common OutputSpan cases.

multispan.append(3)
multispan.append(4)
multispan.append(5)
print("is this thing on? Span count: \(multispan.totalCount)")
Copy link
Member

Choose a reason for hiding this comment

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

Should this stay?

#endif

@frozen @usableFromInline
internal struct MultispanBuffer<Element: ~Copyable> {
Copy link
Member

Choose a reason for hiding this comment

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

NIT: Do you want to keep these shared internal types in this file our should we move them into a separate file?

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.

5 participants