-
Notifications
You must be signed in to change notification settings - Fork 1.2k
InputStream/OutputStream implemented delegate and getBuffer #1667
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
Conversation
@swift-ci please test |
1 similar comment
@swift-ci please test |
@spevans would you mind testing again? |
@swift-ci please test |
Awesome! Maybe a couple simple smoke tests to verify that it's all hooked up correctly? |
@parkera Please find tests. I'm not sure they would work. |
@swift-ci please test |
Not sure what went wrong there. |
@swift-ci clean test |
@parkera I've implemented |
Let's keep them disabled for now. The problem is that the "Autoreleasing" style of pointer is unavailable on Linux. |
@parkera Would you mind mentioning CI to test? |
I still wonder why ClangImporter does not import Autoreleasing pointers as simple |
@swift-ci test |
Autoreleasing has a certain memory management connotation which I don't believe is possible to replicate with just |
Apple can change swift foundation overlay in a way that omit that autoreleasepool. Something like this pseudocode: open class func getStreamsToHost(withName hostname: String, port: Int, inputStream: inout InputStream?, outputStream: inout OutputStream?) {
@autoreleasepool {
var _inputStream: AutoreleasingUnsafeMutablePointer<InputStream?>?
var _outputStream: AutoreleasingUnsafeMutablePointer<InputStream?>?
self._getStreamsToHost(withName: hostname, port: port, inputStream: _inputStream, outputStream: _outputStream)
inputStream = _inputStream.pointee.retain()
outputStreeam = _outputStream.pointee.retain()
}
} |
I don’t understand why test failed |
@swift-ci test |
Looks like the last test ran really slowly for some reason |
It seems |
@amosavian Agreed that we can improve that API. It's on our list. |
@spevans Sorry, would you mind re-test again? |
@swift-ci please test |
Hmm... |
@parkera linux’s XCTest is unable to test asynchronous with multiple fulfilling. Would you if I disable tests until xctest team implement missing features? |
@spevans would you mind retest. I've disabled delegates' test until linux's XCTest can handle expectations with multiple fulfills. This should also resolve compiling issue for now. |
@swift-ci test |
@amosavian I ran the test you added on macOS against the native Foundation library and it failed there (it timed out). |
@spevans You are right. Indeed delegate handle is never triggered. It works in playground when |
Changes:
|
@compnerd I've made Implementing |
@amosavian There is a conflict on this patch now that the Mojave merge has landed. Can you fix that? |
@millenomi done |
@swift-ci please test |
func test_streamDelegate() { | ||
// TODO: macOS/iOS: Fix CFNetwork's dynamic bindings for `callBacks` field. | ||
// TODO: Linux: Enabling delegate/scheduling tests when `CFStreamCreatePairWithSocketToHost()` implemented. | ||
#if false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this point to a specific SR and/or Radar # for follow-up work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure this is a bug or intended behavior. This code crashed in my Xcode. I guess SwiftFoundation fails to load CFNetwork and fill callback pointers in CFStream socket object. (Regarding SwiftFoundation target is primarily Linux and macOS Foundation works fine.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't cause SCF compiled on macOS to crash, because that's a development environment we would like contributors to use. And we should not be picking anything up from CFNetwork in that case either. :(
So something is amiss.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m novice in C and unable to resolve this (don’t know how to fix dynamic loading), unfortunately. Thus I decided to disable the code and hope an expert would fix it later.
Interestingly, afaik no other member of CFReadStream cluster classes are able to use scheduling and I have to stick to socket.
The Swift project moved the default branch to More detail about the branch update - https://forums.swift.org/t/updating-branch-names/40412 |
This PR implements Stream's missing methods including
delegate
,scheduleInRunLoop
andgetBuffer
methods.