Skip to content

[IO] Add leased buffers to the TCP, UDP and file types - #101

Merged
FranzBusch merged 1 commit into
mainfrom
fb-leased-buffer-high-level
Nov 6, 2026
Merged

FranzBusch merged 1 commit into
mainfrom
fb-leased-buffer-high-level

Conversation

@FranzBusch

Copy link
Copy Markdown
Member

Exposes the lease operations on the high-level types.

@FranzBusch
FranzBusch added this pull request to stack #96 October 29, 2026 11:24
@FranzBusch
FranzBusch requested a review from al45tair as a code owner October 29, 2026 11:24
Comment on lines +320 to +331
@available(anyAppleOS 27.0, *)
func readAndWriteWithBuffersFromTheExecutor(ioBackend: PThreadIOBackend) async throws {
try await Self.withTemporaryFile(ioBackend: ioBackend) { path in
let writable = try await File.Writable.open(path: path, options: .newFile(replaceExisting: true))
try await writable.write(at: 0) { span in span.append(bytes: Array("readable and writable".utf8)) }
try await writable.close()

let readable = try await File.Readable.open(path: path)
#expect(try await readable.read(at: 0) { span in span.bytesArray() } == Array("readable and writable".utf8))
try await readable.close()
}
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This also made me think — this interface isn't quite as easy to use as this example makes it look; you don't know what size buffer you've been given, which in principle makes it tricky to write data without building a state machine, since you don't know how much of the information you want to send will actually fit in the buffer.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't think that's true. You can check the size of the buffer through the count property. Our write methods also guarantee that all data is going to be written out. If you do parsing you always need a state machine and probably a buffer.

Base automatically changed from fb-pb2-lease-buffer-schedulers to main November 6, 2026 16:33
@FranzBusch
FranzBusch force-pushed the fb-leased-buffer-high-level branch from d7dec30 to cc12ded Compare November 6, 2026 16:57
Exposes the lease operations on the high-level types.
@FranzBusch
FranzBusch force-pushed the fb-leased-buffer-high-level branch from cc12ded to e52e18f Compare November 6, 2026 17:01
@FranzBusch
FranzBusch merged commit bd74d56 into main Nov 6, 2026
19 of 21 checks passed
@FranzBusch
FranzBusch deleted the fb-leased-buffer-high-level branch November 6, 2026 17:04
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.

2 participants