Skip to content

Commit

Permalink
Added push and pop validation in synchronized block
Browse files Browse the repository at this point in the history
  • Loading branch information
kushCT committed Oct 29, 2024
1 parent 73dbdca commit 3d9748f
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions CleverTapSDK/CTValidationResultStack.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,26 @@ - (void)pushValidationResult:(CTValidationResult *)vr {
CleverTapLogInternal(self.config.logLevel, @"%@: no object in the validation result", self);
return;
}
[self.pendingValidationResults addObject:vr];
if (self.pendingValidationResults && [self.pendingValidationResults count] > 50) {
[self.pendingValidationResults removeObjectAtIndex:0];

@synchronized (self.pendingValidationResults) {
[self.pendingValidationResults addObject:vr];
if (self.pendingValidationResults.count > 50) {
[self.pendingValidationResults removeObjectAtIndex:0];
}
}
}

- (CTValidationResult *)popValidationResult {
CTValidationResult *vr = nil;
if (self.pendingValidationResults && [self.pendingValidationResults count] > 0) {
vr = self.pendingValidationResults[0];
[self.pendingValidationResults removeObjectAtIndex:0];

@synchronized (self.pendingValidationResults) {
if (self.pendingValidationResults.count > 0) {
vr = self.pendingValidationResults[0];
[self.pendingValidationResults removeObjectAtIndex:0];
}
}

return vr;
}


@end

0 comments on commit 3d9748f

Please sign in to comment.