Clean up the use of CFRunLoop. #275

Merged
merged 1 commit into from Jan 22, 2012

Conversation

Projects
None yet
2 participants
Collaborator

erikchen commented Oct 18, 2011

Previously, tasks running from inside the CFRunLoop would call CFRunLoopStop prior to finishing execution. This results in non-deterministic failures to call endBackgroundTask when running iOS tasks in the background with beginBackgroundTaskWithExpirationHandler.
Since the only reason to break out of the CFRunLoop is to flush the autorelease pool, we instead invoke CFRunLoopRunInMode with returnAfterSourceHandled=True, which safely returns and flushes the autorelease pool after each invocation of the CFRunLoop.

@erikchen erikchen Clean up the use of CFRunLoop.
Previously, tasks running from inside the CFRunLoop would call CFRunLoopStop prior to finishing execution. This results in non-deterministic failures to call endBackgroundTask when running iOS tasks in the background with beginBackgroundTaskWithExpirationHandler.
Since the only reason to break out of the CFRunLoop is to flush the autorelease pool, we instead invoke CFRunLoopRunInMode with returnAfterSourceHandled=True, which safely returns and flushes the autorelease pool after each invocation of the CFRunLoop.
80e1dc8

I have someapp crashes where CFRunLoop is involved, but I never activate background or similar.

Can your code fix that crash or is only when background mode is involved?

Thanks.

Collaborator

erikchen commented Jan 20, 2012

conceivable, but highly unlikely.

@erikchen erikchen added a commit that referenced this pull request Jan 22, 2012

@erikchen erikchen Merge pull request #275 from erikchen/master
Clean up the use of CFRunLoop.
d986952

@erikchen erikchen merged commit d986952 into pokeb:master Jan 22, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment