Repository navigation
[IO] Add leased buffers to the TCP, UDP and file types - #101
Merged
Merged
Conversation
al45tair
approved these changes
Nov 4, 2026
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() | ||
| } | ||
| } |
Collaborator
There was a problem hiding this comment.
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.
Member
Author
There was a problem hiding this comment.
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.
FranzBusch
force-pushed
the
fb-leased-buffer-high-level
branch
from
November 6, 2026 16:57
d7dec30 to
cc12ded
Compare
Exposes the lease operations on the high-level types.
FranzBusch
force-pushed
the
fb-leased-buffer-high-level
branch
from
November 6, 2026 17:01
cc12ded to
e52e18f
Compare
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.
Exposes the lease operations on the high-level types.