mirror of
https://github.com/transmission/transmission
synced 2024-12-22 07:42:37 +00:00
only use a single concurrent queue for timeMachineExclude instead of one queue per torrent (#6523)
* only use a single concurrent queue for timeMachineExclude instead of one queue per torrent * moving to +initialize for now (will become a `static let` in Swift anyway) * DISPATCH_QUEUE_SERIAL because DISPATCH_QUEUE_CONCURRENT is limited to 64 simultaneous torrent dispatch_async * `static` is better than `global`, to make it private to a single compilation unit
This commit is contained in:
parent
a51f08e532
commit
81008a1692
4 changed files with 23 additions and 9 deletions
|
@ -345,6 +345,9 @@ static void removeKeRangerRansomware()
|
||||||
|
|
||||||
+ (void)initialize
|
+ (void)initialize
|
||||||
{
|
{
|
||||||
|
if (self != [Controller self])
|
||||||
|
return;
|
||||||
|
|
||||||
removeKeRangerRansomware();
|
removeKeRangerRansomware();
|
||||||
|
|
||||||
//make sure another Transmission.app isn't running already
|
//make sure another Transmission.app isn't running already
|
||||||
|
|
|
@ -56,7 +56,7 @@ typedef NS_ENUM(NSUInteger, TrackerSegmentTag) {
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
NSMutableSet* creatorWindowControllerSet = nil;
|
static NSMutableSet* creatorWindowControllerSet;
|
||||||
|
|
||||||
@implementation CreatorWindowController
|
@implementation CreatorWindowController
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,8 @@ NSString* const kTorrentDidChangeGroupNotification = @"TorrentDidChangeGroup";
|
||||||
|
|
||||||
static int const kETAIdleDisplaySec = 2 * 60;
|
static int const kETAIdleDisplaySec = 2 * 60;
|
||||||
|
|
||||||
|
static dispatch_queue_t timeMachineExcludeQueue;
|
||||||
|
|
||||||
@interface Torrent ()
|
@interface Torrent ()
|
||||||
|
|
||||||
@property(nonatomic, readonly) tr_torrent* fHandle;
|
@property(nonatomic, readonly) tr_torrent* fHandle;
|
||||||
|
@ -45,8 +47,6 @@ static int const kETAIdleDisplaySec = 2 * 60;
|
||||||
|
|
||||||
@property(nonatomic) BOOL fResumeOnWake;
|
@property(nonatomic) BOOL fResumeOnWake;
|
||||||
|
|
||||||
@property(nonatomic) dispatch_queue_t timeMachineExcludeQueue;
|
|
||||||
|
|
||||||
- (void)renameFinished:(BOOL)success
|
- (void)renameFinished:(BOOL)success
|
||||||
nodes:(NSArray<FileListNode*>*)nodes
|
nodes:(NSArray<FileListNode*>*)nodes
|
||||||
completionHandler:(void (^)(BOOL))completionHandler
|
completionHandler:(void (^)(BOOL))completionHandler
|
||||||
|
@ -98,6 +98,15 @@ bool trashDataFile(char const* filename, void* /*user_data*/, tr_error* error)
|
||||||
|
|
||||||
@implementation Torrent
|
@implementation Torrent
|
||||||
|
|
||||||
|
+ (void)initialize
|
||||||
|
{
|
||||||
|
if (self != [Torrent self])
|
||||||
|
return;
|
||||||
|
|
||||||
|
// DISPATCH_QUEUE_SERIAL because DISPATCH_QUEUE_CONCURRENT is limited to 64 simultaneous torrent dispatch_async
|
||||||
|
timeMachineExcludeQueue = dispatch_queue_create("updateTimeMachineExclude", DISPATCH_QUEUE_SERIAL);
|
||||||
|
}
|
||||||
|
|
||||||
- (instancetype)initWithPath:(NSString*)path
|
- (instancetype)initWithPath:(NSString*)path
|
||||||
location:(NSString*)location
|
location:(NSString*)location
|
||||||
deleteTorrentFile:(BOOL)torrentDelete
|
deleteTorrentFile:(BOOL)torrentDelete
|
||||||
|
@ -1826,7 +1835,6 @@ bool trashDataFile(char const* filename, void* /*user_data*/, tr_error* error)
|
||||||
name:@"GroupValueRemoved"
|
name:@"GroupValueRemoved"
|
||||||
object:nil];
|
object:nil];
|
||||||
|
|
||||||
_timeMachineExcludeQueue = dispatch_queue_create("updateTimeMachineExclude", DISPATCH_QUEUE_CONCURRENT);
|
|
||||||
[self update];
|
[self update];
|
||||||
[self updateTimeMachineExclude];
|
[self updateTimeMachineExclude];
|
||||||
|
|
||||||
|
@ -2157,7 +2165,7 @@ bool trashDataFile(char const* filename, void* /*user_data*/, tr_error* error)
|
||||||
NSString* path;
|
NSString* path;
|
||||||
if ((path = self.dataLocation))
|
if ((path = self.dataLocation))
|
||||||
{
|
{
|
||||||
dispatch_async(_timeMachineExcludeQueue, ^{
|
dispatch_async(timeMachineExcludeQueue, ^{
|
||||||
CFURLRef url = (__bridge CFURLRef)[NSURL fileURLWithPath:path];
|
CFURLRef url = (__bridge CFURLRef)[NSURL fileURLWithPath:path];
|
||||||
CSBackupSetItemExcluded(url, exclude, false);
|
CSBackupSetItemExcluded(url, exclude, false);
|
||||||
});
|
});
|
||||||
|
|
|
@ -20,6 +20,10 @@ static CGFloat const kPaddingBetweenLines = 1.0;
|
||||||
static CGFloat const kPaddingBetweenLinesOnSameLine = 4.0;
|
static CGFloat const kPaddingBetweenLinesOnSameLine = 4.0;
|
||||||
static CGFloat const kCountWidth = 60.0;
|
static CGFloat const kCountWidth = 60.0;
|
||||||
|
|
||||||
|
// make the favicons accessible to all tracker cells
|
||||||
|
static NSCache* fTrackerIconCache;
|
||||||
|
static NSMutableSet* fTrackerIconLoading;
|
||||||
|
|
||||||
@interface TrackerCell ()
|
@interface TrackerCell ()
|
||||||
|
|
||||||
@property(nonatomic, readonly) NSImage* favIcon;
|
@property(nonatomic, readonly) NSImage* favIcon;
|
||||||
|
@ -31,12 +35,11 @@ static CGFloat const kCountWidth = 60.0;
|
||||||
|
|
||||||
@implementation TrackerCell
|
@implementation TrackerCell
|
||||||
|
|
||||||
//make the favicons accessible to all tracker cells
|
|
||||||
NSCache* fTrackerIconCache;
|
|
||||||
NSMutableSet* fTrackerIconLoading;
|
|
||||||
|
|
||||||
+ (void)initialize
|
+ (void)initialize
|
||||||
{
|
{
|
||||||
|
if (self != [TrackerCell self])
|
||||||
|
return;
|
||||||
|
|
||||||
fTrackerIconCache = [[NSCache alloc] init];
|
fTrackerIconCache = [[NSCache alloc] init];
|
||||||
fTrackerIconLoading = [[NSMutableSet alloc] init];
|
fTrackerIconLoading = [[NSMutableSet alloc] init];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue