forked from project-chip/connectedhomeip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMTRDeviceStorageBehaviorConfiguration.h
98 lines (88 loc) · 4.89 KB
/
MTRDeviceStorageBehaviorConfiguration.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/**
* Copyright (c) 2024 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#import <Foundation/Foundation.h>
#import <Matter/MTRDefines.h>
NS_ASSUME_NONNULL_BEGIN
/**
* Class that configures how MTRDevice objects persist their attributes to storage, so as to not
* overwhelm the underlying storage system.
*/
MTR_AVAILABLE(ios(17.6), macos(14.6), watchos(10.6), tvos(17.6))
@interface MTRDeviceStorageBehaviorConfiguration : NSObject <NSCopying>
/**
* Create configuration with a default set of values. See description below for details.
*/
+ (instancetype)configurationWithDefaultStorageBehavior;
/**
* Create configuration that disables storage behavior optimizations.
*/
+ (instancetype)configurationWithStorageBehaviorOptimizationDisabled;
/**
* Create configuration with specified values. See description below for details, and the list of
* properties below for valid ranges of these values.
*/
+ (instancetype)configurationWithReportToPersistenceDelayTime:(NSTimeInterval)reportToPersistenceDelayTime
reportToPersistenceDelayTimeMax:(NSTimeInterval)reportToPersistenceDelayTimeMax
recentReportTimesMaxCount:(NSUInteger)recentReportTimesMaxCount
timeBetweenReportsTooShortThreshold:(NSTimeInterval)timeBetweenReportsTooShortThreshold
timeBetweenReportsTooShortMinThreshold:(NSTimeInterval)timeBetweenReportsTooShortMinThreshold
reportToPersistenceDelayMaxMultiplier:(double)reportToPersistenceDelayMaxMultiplier
deviceReportingExcessivelyIntervalThreshold:(NSTimeInterval)deviceReportingExcessivelyIntervalThreshold;
/**
* Storage behavior with values in the allowed range:
*
* Each time a report comes in, MTRDevice will wait reportToPersistDelayTime before persisting the
* changes to storage. If another report comes in during this internal, MTRDevice will wait another
* reportToPersistDelayTime interval, until reportToPersistDelayTimeMax is reached, at which
* point all the changes so far will be written to storage.
*
* MTRDevice will also track recentReportTimesMaxCount number of report times. If the running
* average time between reports dips below timeBetweenReportsTooShortThreshold, a portion of the
* reportToPersistenceDelayMaxMultiplier will be applied to both the reportToPersistenceDelayTime
* and reportToPersistenceDelayTimeMax. The multiplier will reach the max when the average time
* between reports reach timeBetweenReportsTooShortMinThreshold.
*
* When the running average time between reports dips below timeBetweenReportsTooShortMinThreshold
* for the first time, the time will be noted. If the device remains in this state for longer than
* deviceReportingExcessivelyIntervalThreshold, persistence will stop until the average time between
* reports go back above timeBetweenReportsTooShortMinThreshold.
*/
/**
* If disableStorageBehaviorOptimization is set to YES, then all the waiting mechanism as described above
* is disabled.
*/
@property (nonatomic, assign) BOOL disableStorageBehaviorOptimization;
/**
* If any of these properties are set to be out of the documented limits, these default values will
* be used to replace all of them:
*
* reportToPersistenceDelayTimeDefault (15)
* reportToPersistenceDelayTimeMaxDefault (20 * 15)
* recentReportTimesMaxCountDefault (12)
* timeBetweenReportsTooShortThresholdDefault (15)
* timeBetweenReportsTooShortMinThresholdDefault (5)
* reportToPersistenceDelayMaxMultiplierDefault (10)
* deviceReportingExcessivelyIntervalThresholdDefault (5 * 60)
*/
@property (nonatomic, assign) NSTimeInterval reportToPersistenceDelayTime; /* must be > 0 */
@property (nonatomic, assign) NSTimeInterval reportToPersistenceDelayTimeMax; /* must be larger than reportToPersistenceDelayTime */
@property (nonatomic, assign) NSUInteger recentReportTimesMaxCount; /* must be >= 2 */
@property (nonatomic, assign) NSTimeInterval timeBetweenReportsTooShortThreshold; /* must be > 0 */
@property (nonatomic, assign) NSTimeInterval timeBetweenReportsTooShortMinThreshold; /* must be > 0 and smaller than timeBetweenReportsTooShortThreshold */
@property (nonatomic, assign) double reportToPersistenceDelayMaxMultiplier; /* must be > 1 */
@property (nonatomic, assign) NSTimeInterval deviceReportingExcessivelyIntervalThreshold; /* must be > 0 */
@end
NS_ASSUME_NONNULL_END