Changeset 14118


Ignore:
Timestamp:
Jul 14, 2013, 2:28:40 PM (9 years ago)
Author:
livings124
Message:

Perform callbacks in the Torrent class using GCD.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Torrent.m

    r14077 r14118  
    6565void startQueueCallback(tr_torrent * torrent, void * torrentData)
    6666{
    67     [(Torrent *)torrentData performSelectorOnMainThread: @selector(startQueue) withObject: nil waitUntilDone: NO];
     67    dispatch_async(dispatch_get_main_queue(), ^{
     68        [(Torrent *)torrentData startQueue];
     69    });
    6870}
    6971
    7072void completenessChangeCallback(tr_torrent * torrent, tr_completeness status, bool wasRunning, void * torrentData)
    7173{
    72     @autoreleasepool
    73     {
     74    dispatch_async(dispatch_get_main_queue(), ^{
    7475        NSDictionary * dict = [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt: status], @"Status",
    7576                               [NSNumber numberWithBool: wasRunning], @"WasRunning", nil];
    76         [(Torrent *)torrentData performSelectorOnMainThread: @selector(completenessChange:) withObject: dict waitUntilDone: NO];
    77     }
     77        [(Torrent *)torrentData completenessChange: dict];
     78    });
    7879}
    7980
    8081void ratioLimitHitCallback(tr_torrent * torrent, void * torrentData)
    8182{
    82     [(Torrent *)torrentData performSelectorOnMainThread: @selector(ratioLimitHit) withObject: nil waitUntilDone: NO];
     83    dispatch_async(dispatch_get_main_queue(), ^{
     84        [(Torrent *)torrentData ratioLimitHit];
     85    });
    8386}
    8487
    8588void idleLimitHitCallback(tr_torrent * torrent, void * torrentData)
    8689{
    87     [(Torrent *)torrentData performSelectorOnMainThread: @selector(idleLimitHit) withObject: nil waitUntilDone: NO];
     90    dispatch_async(dispatch_get_main_queue(), ^{
     91        [(Torrent *)torrentData idleLimitHit];
     92    });
    8893}
    8994
    9095void metadataCallback(tr_torrent * torrent, void * torrentData)
    9196{
    92     [(Torrent *)torrentData performSelectorOnMainThread: @selector(metadataRetrieved) withObject: nil waitUntilDone: NO];
     97    dispatch_async(dispatch_get_main_queue(), ^{
     98        [(Torrent *)torrentData metadataRetrieved];
     99    });
    93100}
    94101
Note: See TracChangeset for help on using the changeset viewer.