Skip to content

Commit

Permalink
Add ability to configure maxConcurrentOperations (#329)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
andyfinnell authored May 10, 2024
1 parent 803c069 commit 8ad8111
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Source/PINCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ PIN_SUBCLASSING_RESTRICTED
*/
@property (readonly) NSUInteger diskByteCount;

/**
Sets/gets the maximum number of concurrent operations when handling async requests.
*/
@property (nonatomic) NSUInteger maxConcurrentOperations;

/**
The underlying disk cache, see <PINDiskCache> for additional configuration and trimming options.
*/
Expand Down
10 changes: 10 additions & 0 deletions Source/PINCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,16 @@ - (void)removeAllObjects
[_diskCache removeAllObjects];
}

- (NSUInteger)maxConcurrentOperations
{
return _operationQueue.maxConcurrentOperations;
}

- (void)setMaxConcurrentOperations:(NSUInteger)maxOperations
{
_operationQueue.maxConcurrentOperations = maxOperations;
}

@end

@implementation PINCache (Deprecated)
Expand Down

0 comments on commit 8ad8111

Please sign in to comment.