Skip to content
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

Closed
wants to merge 1 commit into from
Closed

Conversation

r10s
Copy link
Member

@r10s r10s commented May 18, 2021

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 the completionHandler, even if performFetch() 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.

@r10s r10s requested a review from cyBerta May 18, 2021 13:25
completionHandler(.newData)
logger.info("⬅️ fetch done")
completionHandler(.newData)
self.unregisterFetchBackgroundTask()
Copy link
Contributor

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.

Copy link
Member Author

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
Copy link
Contributor

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()?

@cyBerta
Copy link
Contributor

cyBerta commented May 18, 2021

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 🌶️🌶️🌶️

@r10s
Copy link
Member Author

r10s commented May 18, 2021

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 :)

@r10s
Copy link
Member Author

r10s commented May 18, 2021

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

@r10s r10s force-pushed the tweak-background-tasks branch from 0bb5d7d to 3f8a66c Compare May 19, 2021 08:40
@r10s r10s changed the title tweak background tasks stop performFetch by a function May 19, 2021
@r10s
Copy link
Member Author

r10s commented May 19, 2021

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.

@r10s
Copy link
Member Author

r10s commented May 19, 2021

closing in favor to #1223

@r10s r10s closed this May 19, 2021
@r10s r10s added the notify label May 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants