-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
FileWatching: cleanup timers on return #36301
Conversation
Following my own advice at #36217. Avoids a minor temporary resource leak.
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.
Just looking at the diff, but yeah, using Timer
is a nice solution for this 👍
@@ -649,10 +649,13 @@ giving the result of the polling. | |||
function poll_fd(s::Union{RawFD, Sys.iswindows() ? WindowsRawSocket : Union{}}, timeout_s::Real=-1; readable=false, writable=false) | |||
wt = Condition() | |||
fdw = _FDWatcher(s, readable, writable) | |||
local timer |
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.
Just curious, but why not timer = nothing
and later timer === nothing || close(timer)
? Is it some kind of optimization or just a coding style?
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.
True, those would be essentially same. So just equivalent variations based on how I started writing it.
There's perhaps a chance this broke something (https://build.julialang.org/#/builders/79/builds/863/steps/5/logs/stdio), though I don't see how, but let's keep an eye on that. |
Following my own advice at JuliaLang#36217. Avoids a minor temporary resource leak.
Following my own advice at JuliaLang#36217. Avoids a minor temporary resource leak.
Following discussion and my own advice at #36217, this avoids a minor temporary resource leak when using the
timeout
parameter. Can't really be tested as there's no visible side effects to this.