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

Multiple processes sharing PINCache #2

Open
ebgraham opened this issue Mar 27, 2015 · 5 comments
Open

Multiple processes sharing PINCache #2

ebgraham opened this issue Mar 27, 2015 · 5 comments

Comments

@ebgraham
Copy link

To support notification center and Apple Watch extensions, we'd like to move our cache location to a shared app group container. However this enables multiple processes to simultaneously attempt to read and write on the same files. Does PINCache have any protection against this, by using NSFileCoordinator, for example?

@garrettmoon
Copy link
Collaborator

No, it uses a runtime lock to protect file access. However, that sounds like a good enhancement to be made!

@garrettmoon
Copy link
Collaborator

Looked into using NSFileCoordinator a bit.

One problem:
"If your app enters the background with an active file presenter, any other processes that perform a coordinated read or write on the presented file can deadlock. To prevent this situation, call removeFilePresenter: to remove the file presenter in the applicationDidEnterBackground: method or in response to a UIApplicationDidEnterBackgroundNotification notification. Call addFilePresenter: to add the file presenter again in the applicationWillEnterForeground: method or in response to a UIApplicationWillEnterForegroundNotification notification."

This may be an issue with extensions as notifications for backgrounding don't occur if I'm not mistaken.

@ebgraham
Copy link
Author

Extensions do actually get little-known lifecycle notifications:

NSExtensionHostDidBecomeActiveNotification
NSExtensionHostDidEnterBackgroundNotification
NSExtensionHostWillEnterForegroundNotification
NSExtensionHostWillResignActiveNotification

@garrettmoon
Copy link
Collaborator

Ahh! Nice!

The next concern I have is around performance. That's the next question to tackle :)

@ghost
Copy link

ghost commented Aug 5, 2019

Has this been implemented?

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

No branches or pull requests

2 participants