-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
MingwX64 support ? #743
Comments
That might be it. Send a PR? |
👍 I added the target and CI build but it chokes on tests: https://github.com/martinbonnin/okio/runs/929628421?check_suite_focus=true. Will keep looking. |
Small update: there are at least three different flavors of errors:
|
Thanks for digging into this! For the timing thing it should be fine to relax the tests. I assume the underlying wait mechanisms aren’t precise enough. |
Kotlin 1.4 fixed the compiler error 🎉 . The only thing left is the timing error. Relaxing the tests is most likely not enough, or we would have to relax them a lot for the |
@martinbonnin There's no guarantee on
|
Indeed 👍 . It's weird that on Windows, this always happens a few nanoseconds before the timeout, which makes it look more like inaccurate timers than spurious wakeups but in the end it's the same result. What this all means is that the Replace synchronized(buffer) {
check(!sourceClosed) { "closed" }
if (canceled) throw IOException("canceled")
while (buffer.size == 0L) {
if (sinkClosed) return -1L
timeout.waitUntilNotified(buffer) // Wait until the sink fills the buffer.
if (canceled) throw IOException("canceled")
}
val result = buffer.read(sink, byteCount)
(buffer as Object).notifyAll() // Notify the sink that it can resume writing.
return result
} with something like: synchronized(buffer) {
check(!sourceClosed) { "closed" }
if (canceled) throw IOException("canceled")
val start = timeout.nanoTime()
while (buffer.size == 0L) {
val remainingTime = timeout.remainingTime(start)
if (remainingTime <= 0) {
throw InterruptedIOException("timeout")
}
if (sinkClosed) return -1L
buffer.wait(remainingTime)
if (canceled) throw IOException("canceled")
}
val result = buffer.read(sink, byteCount)
(buffer as Object).notifyAll() // Notify the sink that it can resume writing.
return result
} @swankjesse any thoughts about adding If that works for you, I could modify the places needed to make the windows tests pass (Pipe.kt, maybe a few others) and leave the other untouched? |
No, I don't like that. If we wanted to change the API to mitigate spurious wakeups, it could take a lambda with a condition.
|
Also - there's a difference between spurious wakeups and bad timer resolution. Spurious wakeups haven't been a problem in my experience. The effect I'm aware of is notify() wakes up multiple waiters instead of exactly one. Bad timer resolution is waking up a few ns early. I don't think this is problematic in practice either. If you look at the source code of OpenJDK’s |
🙈
To clarify, the proposal is to not use
This API would need to have the object to wait on passed as a param so maybe something like |
Yup, that. |
What would be needed to get mingwX64 support? adding the target? updating CI and publication? Anything else?
The text was updated successfully, but these errors were encountered: