-
-
Notifications
You must be signed in to change notification settings - Fork 52
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
stop performFetch by a function #1220
Conversation
completionHandler(.newData) | ||
logger.info("⬅️ fetch done") | ||
completionHandler(.newData) | ||
self.unregisterFetchBackgroundTask() |
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.
maybe we should move that line before the completion handler is executed in order to be sure this is called before the suspension of the app happened.
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 think, this is fine, the backgroundTask avoids the suspension.
// the plan is to listen to an event as DC_EVENT_ENTER_IDLE and stop fetch from there. | ||
// if we have such an event, we could imprive this handler and fire the event. | ||
logger.info("fetch background task will end soon") | ||
fetchBackgroundTaskEnding = 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.
this is quite confusing to read. Is it possible to move that line to the end of endFetch()
?
For the naming of the background task, maybe we can find sth. more descriptive. Afterburner reminds me of other things than what is meant here 🌶️🌶️🌶️ |
please do not merge in, i have an idea about how to do this whole stuff more elegant with less "globals", have to think about that a bit more, however :) |
i crated an alternative in #1221 and removed "afterburner" wording, i was searching for sth. as "nachlaufen" or "auslaufen", but, yes, afterburner seems to to be exactly that. this is my association: btw. "afterburner" reminds me more to https://www.youtube.com/watch?v=XfsillAQdHg |
0bb5d7d
to
3f8a66c
Compare
this pr, although having more complexity, as the same issue as #1221 - it does not call endBackgroundTask from within the handler but a moment later. |
closing in favor to #1223 |
still targets 0xdead10cc, #1202
i did not create an observer yet as this would mean additional complexity. however, when we need it because of #1157, all these changes will already help.
we need to take care that
performFetch()
always calls thecompletionHandler
, even ifperformFetch()
is called concurrently. this is mainly achieved by the time-check, allowing this function only once per minute. otherwise, things would be even more complicated.