-
Notifications
You must be signed in to change notification settings - Fork 652
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
Add async variant of ByteBuffer.withUnsafeReadableBytes. #2694
base: main
Are you sure you want to change the base?
Add async variant of ByteBuffer.withUnsafeReadableBytes. #2694
Conversation
Hi @ser-0xff, what's the intended use-case of this function? It generally gives me the heeby-jeebies because it can easily lead to sendability or law of exclusivity violations. |
Hi, @Lukasa
|
That makes total sense: I think my core question is just why you need an unsafe pointer through an async boundary. Is it possible to use something safer at that layer? |
We could propagate ByteBuffer further to the data processing layer, but it is different package where we would not like to have a dependency on swift-nio. Anyway, if you think it is dangerous let's close PR then. |
Maybe the longer term would be the adoption of BufferView (https://gist.github.com/atrick/4fab6886518f756295f77445e4bf0788) when it happens to avoid depending on NIO for ByteBuffer? Have there been any thoughts on how that would dovetail with current ByteBuffer usage in SwiftNIO? |
So using something like In the longer term, we'll adopt |
Thank you for the update! |
Add async variant of ByteBuffer.withUnsafeReadableBytes<>.
Motivation:
Would be nice to have a possibility to use byte buffers with swift concurrency.
Modifications:
Add async variant of ByteBuffer.withUnsafeReadableBytes<>.
Result:
Having an async variant of ByteBuffer.withUnsafeReadableBytes<> will give a possibility to call async functions from the argument closure.