Skip to content

Commit 8ad8111

Browse files
authored
Add ability to configure maxConcurrentOperations (#329)
* Add ability to configure maxConcurrentOperations ## Summary PINCache uses a PINOperationQueue to perform async operations on a background queue, while preventing thread explosion. However, the amount is hardcoded to 10 and I'd like to be able to experiment with how much concurrency we use. Therefore, add a property to allow it to be configuration. ## Testing Since it's just a configuration parameter, make sure the unit tests still pass. * Only PINCache implements the property so move it there instead of the protocol * Nudge github actions
1 parent 803c069 commit 8ad8111

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

Source/PINCache.h

+5
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ PIN_SUBCLASSING_RESTRICTED
4242
*/
4343
@property (readonly) NSUInteger diskByteCount;
4444

45+
/**
46+
Sets/gets the maximum number of concurrent operations when handling async requests.
47+
*/
48+
@property (nonatomic) NSUInteger maxConcurrentOperations;
49+
4550
/**
4651
The underlying disk cache, see <PINDiskCache> for additional configuration and trimming options.
4752
*/

Source/PINCache.m

+10
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,16 @@ - (void)removeAllObjects
389389
[_diskCache removeAllObjects];
390390
}
391391

392+
- (NSUInteger)maxConcurrentOperations
393+
{
394+
return _operationQueue.maxConcurrentOperations;
395+
}
396+
397+
- (void)setMaxConcurrentOperations:(NSUInteger)maxOperations
398+
{
399+
_operationQueue.maxConcurrentOperations = maxOperations;
400+
}
401+
392402
@end
393403

394404
@implementation PINCache (Deprecated)

0 commit comments

Comments
 (0)