Skip to content

Commit

Permalink
Introduce MTRAsyncWorkItemRetryCountBase
Browse files Browse the repository at this point in the history
  • Loading branch information
ksperling-apple committed Sep 28, 2023
1 parent 8592ff4 commit 315226c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/darwin/Framework/CHIP/MTRAsyncWorkQueue.mm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ typedef NS_ENUM(NSInteger, MTRAsyncWorkItemState) {
MTRAsyncWorkItemComplete,
MTRAsyncWorkItemEnqueued,
MTRAsyncWorkItemRunning,
// values > MTRAsyncWorkItemRunning encode retryCount
MTRAsyncWorkItemRetryCountBase = MTRAsyncWorkItemRunning, // values >= MTRAsyncWorkItemRunning encode retryCount
};

MTR_DIRECT_MEMBERS
Expand Down Expand Up @@ -97,7 +97,7 @@ - (NSInteger)retryCount
case MTRAsyncWorkItemEnqueued:
return 0;
default:
return ((NSInteger) _state) - MTRAsyncWorkItemRunning;
return ((NSInteger) _state) - MTRAsyncWorkItemRetryCountBase;
}
}

Expand All @@ -109,8 +109,8 @@ - (void)callReadyHandlerWithContext:(id)context completion:(MTRAsyncWorkCompleti
if (_state == MTRAsyncWorkItemEnqueued) {
_state = MTRAsyncWorkItemRunning;
} else if (_state >= MTRAsyncWorkItemRunning) {
retryCount = (_state - MTRAsyncWorkItemRunning) + 1; // increment retryCount
_state = (MTRAsyncWorkItemState) (MTRAsyncWorkItemRunning + retryCount);
retryCount = (_state - MTRAsyncWorkItemRetryCountBase) + 1; // increment retryCount
_state = (MTRAsyncWorkItemState) (MTRAsyncWorkItemRetryCountBase + retryCount);
} else {
return; // asserted above
}
Expand Down

0 comments on commit 315226c

Please sign in to comment.