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

Use GCD instead of threads #27

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

triplef
Copy link

@triplef triplef commented Jul 22, 2011

Was previously creating a new thread for every call to +userDidSignificantEvent, +appEnteredForeground, and +appLaunched, which is unnecessarily expensive (especially for apps calling userDidSignificantEvent often).

Was previously creating a new thread for every call to +userDidSignifica
ntEvent, +appEnteredForeground, and +appLaunched.
@meachware
Copy link
Contributor

AWESOME work!
I just revised your version with this dispatch_once singleton:
I've been reading up on race conditions with older style singletons and I "believe" this style is safe, secure and thread safe.

#pragma mark GCD Singleton
static Appirater *appirater = nil;

  • (Appirater*)sharedInstance {

    if (appirater) return appirater;

    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
    appirater = [[Appirater alloc] init];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWillResignActive) name:@"UIApplicationWillResignActiveNotification" object:nil];
    });
    return appirater;
    }

@triplef
Copy link
Author

triplef commented Jul 27, 2011

Good idea! Just changed it to use dispatch_once. Thanks!

@meachware
Copy link
Contributor

np - I've been testing your commit the last few days and no problems - nice update!

@arashpayan
Copy link
Owner

I like the idea of using GCD, but I need to make sure Appirater remains compatible for developers who still need to deploy on iOS3 devices (myself included :-/ ).

@meachware
Copy link
Contributor

@arashpayan - no problem, except Apple will be making that decision for you (meaning say around iOS 5.1 or 5.2, Apple will bump the min OS and remove 3.x from the list, for new apps). :-) Of course for Game center apps all these "rate my app" projects will no longer be needed in 5.x ( i'll be keeping it in my apps for non-game center users, which there are still a lot of)

@adamjernst
Copy link

+1, can we please use this? It's been 6 months, iOS 3 is barely relevant any more.

@Stunner
Copy link

Stunner commented Nov 22, 2012

iOS 6 is now out... no one cares about the first iteration iPhone. Time to merge this into master? ;)

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

Successfully merging this pull request may close these issues.

5 participants