Skip to content

Commit

Permalink
start closing off MTRDevice direct use
Browse files Browse the repository at this point in the history
  • Loading branch information
kiel-apple committed Aug 3, 2024
1 parent 32b706e commit dea4e7d
Showing 1 changed file with 4 additions and 37 deletions.
41 changes: 4 additions & 37 deletions src/darwin/Framework/CHIP/MTRDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -500,42 +500,8 @@ @implementation MTRDevice {

- (instancetype)initWithNodeID:(NSNumber *)nodeID controller:(MTRDeviceController *)controller
{
if (self = [super init]) {
_lock = OS_UNFAIR_LOCK_INIT;
_timeSyncLock = OS_UNFAIR_LOCK_INIT;
_nodeID = [nodeID copy];
_fabricIndex = controller.fabricIndex;
_deviceController = controller;
_queue
= dispatch_queue_create("org.csa-iot.matter.framework.device.workqueue", DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL);
_expectedValueCache = [NSMutableDictionary dictionary];
_asyncWorkQueue = [[MTRAsyncWorkQueue alloc] initWithContext:self];
_state = MTRDeviceStateUnknown;
_internalDeviceState = MTRInternalDeviceStateUnsubscribed;
if (controller.controllerDataStore) {
_persistedClusterData = [[NSCache alloc] init];
} else {
_persistedClusterData = nil;
}
_clusterDataToPersist = nil;
_persistedClusters = [NSMutableSet set];

// If there is a data store, make sure we have an observer to monitor system clock changes, so
// NSDate-based write coalescing could be reset and not get into a bad state.
if (_persistedClusterData) {
mtr_weakify(self);
_systemTimeChangeObserverToken = [[NSNotificationCenter defaultCenter] addObserverForName:NSSystemClockDidChangeNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull notification) {
mtr_strongify(self);
std::lock_guard lock(self->_lock);
[self _resetStorageBehaviorState];
}];
}

_delegates = [NSMutableSet set];

MTR_LOG_DEBUG("%@ init with hex nodeID 0x%016llX", self, _nodeID.unsignedLongLongValue);
}
return self;
MTR_LOG_ERROR("do not call %s on base class", __func__);
return nil;
}

- (void)dealloc
Expand All @@ -554,7 +520,8 @@ - (NSString *)description

+ (MTRDevice *)deviceWithNodeID:(NSNumber *)nodeID controller:(MTRDeviceController *)controller
{
return [controller deviceForNodeID:nodeID];
MTR_LOG_ERROR("do not call %s on base class", __func__);
return nil;
}

#pragma mark - Time Synchronization
Expand Down

0 comments on commit dea4e7d

Please sign in to comment.