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

dispatch_set_target_queue usage not correct #52

Open
haifenghuang opened this issue Aug 13, 2015 · 1 comment
Open

dispatch_set_target_queue usage not correct #52

haifenghuang opened this issue Aug 13, 2015 · 1 comment

Comments

@haifenghuang
Copy link

In initWithCacheDirectory method of EGOCache.m file, the dispatch_set_target_queue's usage is not correct.

- (instancetype)initWithCacheDirectory:(NSString*)cacheDirectory {
    if((self = [super init])) {
        _cacheInfoQueue = dispatch_queue_create("com.enormego.egocache.info", DISPATCH_QUEUE_SERIAL);
        dispatch_queue_t priority = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);
        dispatch_set_target_queue(priority, _cacheInfoQueue);

        _frozenCacheInfoQueue = dispatch_queue_create("com.enormego.egocache.info.frozen", DISPATCH_QUEUE_SERIAL);
        priority = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);
        dispatch_set_target_queue(priority, _frozenCacheInfoQueue);

        _diskQueue = dispatch_queue_create("com.enormego.egocache.disk", DISPATCH_QUEUE_CONCURRENT);
        priority = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0);
        dispatch_set_target_queue(priority, _diskQueue);

In man page of dispatch_set_target_queue, it has below statements:

The result of passing the main queue or a global concurrent queue as the first argument of dispatch_set_target_queue() is undefined.

So the usage of dispatch_set_target_queue is not correct, the correct usage should be as below:

dispatch_set_target_queue(_cacheInfoQueue, priority);
dispatch_set_target_queue(_frozenCacheInfoQueue, priority);
dispatch_set_target_queue(_diskQueue, priority);
@migrant
Copy link

migrant commented Aug 18, 2015

Yes, I have the same question. Seems like @haifenghuang 's code is correct

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

No branches or pull requests

2 participants