Skip to content

Commit

Permalink
Separate System::Layer and Timer into per-implementation files. (#8800)
Browse files Browse the repository at this point in the history
* Separate System::Layer and Timer into per-implementation files.

#### Problem

Various implementations of System::Layer are provided by `#if` sections,
which prevents mock versions for testing and out-of-tree platform
implementations.

#### Change overview

Split platform `#if` sections of `System::Layer` and `System::Timer`
into separate `WatchableEventManager` implementations.

This change does for timers what PR #6561 did for socket I/O events.
The intent is that the public `WatchableEventManager` interface here
will become pure virtual methods of `System::Layer`, and the various
versions of `WatchableEventManager` will become its implementations.

`System::Timer` remains as an `Object`-pool based utility class for
implementing the Timer API.

- Make `Timer` list not LwIP-specific, mutex it, and use it in preference
  to iterating through the entire pool.
- Move `IsEarlier` from `Timer` to `Clock`.
- Fix dual definitions of `Clock::Platform` functions on Linux.

#### Testing

Relying on CI in general, since no externally visible functionality
should have changed. Sanity-checked the libevent implementation (not in
CI) using chip-tool.

* rebase and regen zap

* Remove obsolete TODO.

* restyle

* remove leftover debug logging

* restyle

* convert outdated ChipError::FormatError()

* review

- add config flag CHIP_SYSTEM_CONFIG_USE_TIMER_POOL
- use std::lock_guard rather than inventing ScopedMutexLock
- rename mWatchableEvents and WatchableEvents()
  • Loading branch information
kpschoedel authored Aug 11, 2021
1 parent da5abd0 commit 2d103c8
Show file tree
Hide file tree
Showing 46 changed files with 1,278 additions and 1,105 deletions.
12 changes: 3 additions & 9 deletions examples/chip-tool/commands/common/Command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,16 +423,10 @@ static void OnResponseTimeout(chip::System::Layer *, void *, CHIP_ERROR)

CHIP_ERROR Command::ScheduleWaitForResponse(uint16_t seconds)
{
chip::System::Timer * timer = nullptr;

CHIP_ERROR err = chip::DeviceLayer::SystemLayer.NewTimer(timer);
if (err == CHIP_NO_ERROR)
{
timer->Start(seconds * 1000, OnResponseTimeout, this);
}
else
CHIP_ERROR err = chip::DeviceLayer::SystemLayer.StartTimer(seconds * 1000, OnResponseTimeout, this);
if (err != CHIP_NO_ERROR)
{
ChipLogError(chipTool, "Failed to allocate timer");
ChipLogError(chipTool, "Failed to allocate timer %" CHIP_ERROR_FORMAT, err.Format());
}
return err;
}
Expand Down
24 changes: 9 additions & 15 deletions examples/minimal-mdns/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,22 +327,16 @@ int main(int argc, char ** args)

BroadcastPacket(&mdnsServer);

System::Timer * timer = nullptr;

if (DeviceLayer::SystemLayer.NewTimer(timer) == CHIP_NO_ERROR)
{
timer->Start(
gOptions.runtimeMs,
[](System::Layer *, void *, CHIP_ERROR err) {
DeviceLayer::PlatformMgr().StopEventLoopTask();
DeviceLayer::PlatformMgr().Shutdown();
},
nullptr);
}
else
CHIP_ERROR err = DeviceLayer::SystemLayer.StartTimer(
gOptions.runtimeMs,
[](System::Layer *, void *, CHIP_ERROR err) {
DeviceLayer::PlatformMgr().StopEventLoopTask();
DeviceLayer::PlatformMgr().Shutdown();
},
nullptr);
if (err != CHIP_NO_ERROR)
{

printf("Failed to create the shutdown timer. Kill with ^C.\n");
printf("Failed to create the shutdown timer. Kill with ^C. %" CHIP_ERROR_FORMAT "\n", err.Format());
}

DeviceLayer::PlatformMgr().RunEventLoop();
Expand Down
5 changes: 0 additions & 5 deletions src/ble/BleLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,6 @@ class DLL_EXPORT BleLayer
CHIP_ERROR CloseAllBleConnections();
CHIP_ERROR CloseBleConnection(BLE_CONNECTION_OBJECT connObj);

CHIP_ERROR ScheduleWork(chip::System::Layer::TimerCompleteFunct aComplete, void * aAppState)
{
return mSystemLayer->ScheduleWork(aComplete, aAppState);
}

/**< Platform interface functions:
* Calling conventions:
Expand Down
2 changes: 1 addition & 1 deletion src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ CHIP_ERROR DeviceController::ServiceEventSignal()
VerifyOrReturnError(mState == State::Initialized, CHIP_ERROR_INCORRECT_STATE);

#if CONFIG_DEVICE_LAYER && (CHIP_SYSTEM_CONFIG_USE_SOCKETS || CHIP_SYSTEM_CONFIG_USE_NETWORK_FRAMEWORK)
DeviceLayer::SystemLayer.WatchableEvents().Signal();
DeviceLayer::SystemLayer.WatchableEventsManager().Signal();
#else
ReturnErrorOnFailure(CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE);
#endif // CONFIG_DEVICE_LAYER && (CHIP_SYSTEM_CONFIG_USE_SOCKETS || CHIP_SYSTEM_CONFIG_USE_NETWORK_FRAMEWORK)
Expand Down
4 changes: 2 additions & 2 deletions src/controller/java/CHIPDeviceController-JNI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ void JNI_OnUnload(JavaVM * jvm, void * reserved)
if (sIOThread != PTHREAD_NULL)
{
sShutdown = true;
sSystemLayer.WatchableEvents().Signal();
sSystemLayer.WatchableEventsManager().Signal();

StackUnlockGuard unlockGuard(JniReferences::GetInstance().GetStackLock());
pthread_join(sIOThread, NULL);
Expand Down Expand Up @@ -1060,7 +1060,7 @@ void * IOThreadMain(void * arg)
// Lock the stack to prevent collisions with Java threads.
pthread_mutex_lock(JniReferences::GetInstance().GetStackLock());

System::WatchableEventManager & watchState = sSystemLayer.WatchableEvents();
System::WatchableEventManager & watchState = sSystemLayer.WatchableEventsManager();
watchState.EventLoopBegins();

// Loop until we are told to exit.
Expand Down
4 changes: 4 additions & 0 deletions src/darwin/Framework/CHIP.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,8 @@
"CHIP_DEVICE_LAYER_TARGET_NRF5=0",
"CHIP_DEVICE_LAYER_TARGET_EFR32=0",
"CHIP_SYSTEM_CONFIG_USE_SOCKETS=1",
"CHIP_SYSTEM_CONFIG_POSIX_LOCKING=0",
"CHIP_SYSTEM_CONFIG_NO_LOCKING=1",
"$(inherited)",
);
HEADER_SEARCH_PATHS = (
Expand Down Expand Up @@ -734,6 +736,8 @@
"CHIP_DEVICE_LAYER_TARGET_NRF5=0",
"CHIP_DEVICE_LAYER_TARGET_EFR32=0",
"CHIP_SYSTEM_CONFIG_USE_SOCKETS=1",
"CHIP_SYSTEM_CONFIG_POSIX_LOCKING=0",
"CHIP_SYSTEM_CONFIG_NO_LOCKING=1",
"$(inherited)",
);
HEADER_SEARCH_PATHS = (
Expand Down
11 changes: 3 additions & 8 deletions src/include/platform/PlatformManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <system/SystemLayer.h>

namespace chip {

namespace DeviceLayer {

class PlatformManagerImpl;
Expand All @@ -36,6 +37,7 @@ class ConfigurationManagerImpl;
class TraitManager;
class ThreadStackManagerImpl;
class TimeSyncManager;

namespace Internal {
class DeviceControlServer;
class FabricProvisioningServer;
Expand Down Expand Up @@ -174,14 +176,7 @@ class PlatformManager
friend class Internal::GenericThreadStackManagerImpl_OpenThread_LwIP;
template <class>
friend class Internal::GenericConfigurationManagerImpl;
// Parentheses used to fix clang parsing issue with these declarations
friend ::CHIP_ERROR(::chip::System::Platform::Eventing::PostEvent)(::chip::System::Layer & aLayer,
::chip::System::Object & aTarget,
::chip::System::EventType aType, uintptr_t aArgument);
friend ::CHIP_ERROR(::chip::System::Platform::Eventing::DispatchEvents)(::chip::System::Layer & aLayer);
friend ::CHIP_ERROR(::chip::System::Platform::Eventing::DispatchEvent)(::chip::System::Layer & aLayer,
::chip::System::Event aEvent);
friend ::CHIP_ERROR(::chip::System::Platform::Eventing::StartTimer)(::chip::System::Layer & aLayer, uint32_t aMilliseconds);
friend class System::PlatformEventing;

/*
* PostEvent can be called safely on any thread without locking the stack.
Expand Down
4 changes: 2 additions & 2 deletions src/include/platform/internal/GenericPlatformManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@ void GenericPlatformManagerImpl<ImplClass>::DispatchEventToSystemLayer(const Chi
CHIP_ERROR err = CHIP_NO_ERROR;

// Invoke the System Layer's event handler function.
err = SystemLayer.HandleEvent(*event->ChipSystemLayerEvent.Target, event->ChipSystemLayerEvent.Type,
event->ChipSystemLayerEvent.Argument);
err = SystemLayer.WatchableEventsManager().HandleEvent(*event->ChipSystemLayerEvent.Target, event->ChipSystemLayerEvent.Type,
event->ChipSystemLayerEvent.Argument);
if (err != CHIP_NO_ERROR)
{
ChipLogError(DeviceLayer, "Error handling CHIP System Layer event (type %d): %s", event->Type, ErrorStr(err));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void GenericPlatformManagerImpl_FreeRTOS<ImplClass>::_RunEventLoop(void)

// Call into the system layer to dispatch the callback functions for all timers
// that have expired.
err = SystemLayer.HandlePlatformTimer();
err = SystemLayer.WatchableEventsManager().HandlePlatformTimer();
if (err != CHIP_NO_ERROR)
{
ChipLogError(DeviceLayer, "Error handling CHIP timers: %s", ErrorStr(err));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ bool GenericPlatformManagerImpl_POSIX<ImplClass>::_IsChipStackLockedByCurrentThr
template <class ImplClass>
CHIP_ERROR GenericPlatformManagerImpl_POSIX<ImplClass>::_StartChipTimer(int64_t aMilliseconds)
{
// TODO(#5556): Integrate timer platform details with WatchableEventManager.

// Let SystemLayer.PrepareSelect() handle timers.
// Let WatchableEventManager.PrepareEvents() handle timers.
return CHIP_NO_ERROR;
}

Expand All @@ -127,7 +125,7 @@ void GenericPlatformManagerImpl_POSIX<ImplClass>::_PostEvent(const ChipDeviceEve
{
mChipEventQueue.Push(*event);

SystemLayer.WatchableEvents().Signal(); // Trigger wake select on CHIP thread
SystemLayer.WatchableEventsManager().Signal(); // Trigger wake select on CHIP thread
}

template <class ImplClass>
Expand Down Expand Up @@ -162,7 +160,7 @@ void GenericPlatformManagerImpl_POSIX<ImplClass>::_RunEventLoop()

Impl()->LockChipStack();

System::WatchableEventManager & watchState = SystemLayer.WatchableEvents();
System::WatchableEventManager & watchState = SystemLayer.WatchableEventsManager();
watchState.EventLoopBegins();
do
{
Expand Down Expand Up @@ -257,7 +255,7 @@ CHIP_ERROR GenericPlatformManagerImpl_POSIX<ImplClass>::_StopEventLoopTask()
// SystemLayer.
//
Impl()->LockChipStack();
SystemLayer.WatchableEvents().Signal();
SystemLayer.WatchableEventsManager().Signal();
Impl()->UnlockChipStack();

pthread_mutex_lock(&mStateLock);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,7 @@ void GenericPlatformManagerImpl_Zephyr<ImplClass>::_UnlockChipStack(void)
template <class ImplClass>
CHIP_ERROR GenericPlatformManagerImpl_Zephyr<ImplClass>::_StartChipTimer(uint32_t aMilliseconds)
{
// TODO(#5556): Integrate timer platform details with WatchableEventManager.

// Let SystemLayer.PrepareSelect() handle timers.
// Let WatchableEventManager.PrepareEvents() handle timers.
return CHIP_NO_ERROR;
}

Expand All @@ -109,7 +107,7 @@ void GenericPlatformManagerImpl_Zephyr<ImplClass>::_PostEvent(const ChipDeviceEv
// k_msgq_put takes `void*` instead of `const void*`. Nonetheless, it should be safe to
// const_cast here and there are components in Zephyr itself which do the same.
if (k_msgq_put(&mChipEventQueue, const_cast<ChipDeviceEvent *>(event), K_NO_WAIT) == 0)
SystemLayer.WatchableEvents().Signal(); // Trigger wake on CHIP thread
SystemLayer.WatchableEventsManager().Signal(); // Trigger wake on CHIP thread
else
ChipLogError(DeviceLayer, "Failed to post event to CHIP Platform event queue");
}
Expand All @@ -128,7 +126,7 @@ void GenericPlatformManagerImpl_Zephyr<ImplClass>::_RunEventLoop(void)
{
Impl()->LockChipStack();

System::WatchableEventManager & watchState = SystemLayer.WatchableEvents();
System::WatchableEventManager & watchState = SystemLayer.WatchableEventsManager();
watchState.EventLoopBegins();
while (true)
{
Expand Down
2 changes: 1 addition & 1 deletion src/inet/EndPointBasis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void EndPointBasis::InitEndPointBasis(InetLayer & aInetLayer, void * aAppState)
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP

#if CHIP_SYSTEM_CONFIG_USE_SOCKETS
(void) mSocket.Init(aInetLayer.SystemLayer()->WatchableEvents());
(void) mSocket.Init(aInetLayer.SystemLayer()->WatchableEventsManager());
#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS
}

Expand Down
4 changes: 2 additions & 2 deletions src/inet/IPEndPointBasis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -661,8 +661,8 @@ IPPacketInfo * IPEndPointBasis::GetPacketInfo(const System::PacketBufferHandle &
CHIP_ERROR IPEndPointBasis::PostPacketBufferEvent(chip::System::Layer & aLayer, System::Object & aTarget,
System::EventType aEventType, System::PacketBufferHandle && aBuffer)
{
const CHIP_ERROR error =
aLayer.PostEvent(aTarget, aEventType, (uintptr_t) System::LwIPPacketBufferView::UnsafeGetLwIPpbuf(aBuffer));
const CHIP_ERROR error = aLayer.WatchableEventsManager().PostEvent(
aTarget, aEventType, (uintptr_t) System::LwIPPacketBufferView::UnsafeGetLwIPpbuf(aBuffer));
if (error == CHIP_NO_ERROR)
{
// If PostEvent() succeeded, it has ownership of the buffer, so we need to release it (without freeing it).
Expand Down
2 changes: 1 addition & 1 deletion src/inet/InetLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ CHIP_ERROR InetLayer::Init(chip::System::Layer & aSystemLayer, void * aContext)
err = InitQueueLimiter();
SuccessOrExit(err);

mSystemLayer->AddEventHandlerDelegate(sInetEventHandlerDelegate);
mSystemLayer->WatchableEventsManager().AddEventHandlerDelegate(sInetEventHandlerDelegate);
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP

State = kState_Initialized;
Expand Down
2 changes: 1 addition & 1 deletion src/inet/RawEndPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ CHIP_ERROR RawEndPoint::Bind(IPAddressType addrType, const IPAddress & addr, Int
ReturnErrorOnFailure(IPEndPointBasis::Bind(addrType, addr, 0, intfId));

#if CHIP_SYSTEM_CONFIG_USE_DISPATCH
dispatch_queue_t dispatchQueue = SystemLayer().GetDispatchQueue();
dispatch_queue_t dispatchQueue = SystemLayer().WatchableEventsManager().GetDispatchQueue();
if (dispatchQueue != nullptr)
{
unsigned long fd = static_cast<unsigned long>(mSocket.GetFD());
Expand Down
19 changes: 11 additions & 8 deletions src/inet/TCPEndPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ CHIP_ERROR TCPEndPoint::Bind(IPAddressType addrType, const IPAddress & addr, uin
}

#if CHIP_SYSTEM_CONFIG_USE_DISPATCH
dispatch_queue_t dispatchQueue = SystemLayer().GetDispatchQueue();
dispatch_queue_t dispatchQueue = SystemLayer().WatchableEventsManager().GetDispatchQueue();
if (dispatchQueue != nullptr)
{
unsigned long fd = static_cast<unsigned long>(mSocket.GetFD());
Expand Down Expand Up @@ -843,7 +843,7 @@ void TCPEndPoint::EnableReceive()

#if CHIP_SYSTEM_CONFIG_USE_SOCKETS || CHIP_SYSTEM_CONFIG_USE_NETWORK_FRAMEWORK
// Wake the thread waiting for I/O so that it can include the socket.
SystemLayer().WatchableEvents().Signal();
SystemLayer().WatchableEventsManager().Signal();
#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS || CHIP_SYSTEM_CONFIG_USE_NETWORK_FRAMEWORK
}

Expand Down Expand Up @@ -2204,7 +2204,8 @@ err_t TCPEndPoint::LwIPHandleConnectComplete(void * arg, struct tcp_pcb * tpcb,

// Post callback to HandleConnectComplete.
conErr = chip::System::MapErrorLwIP(lwipErr);
if (lSystemLayer.PostEvent(*ep, kInetEvent_TCPConnectComplete, static_cast<uintptr_t>(conErr.AsInteger())) != CHIP_NO_ERROR)
if (lSystemLayer.WatchableEventsManager().PostEvent(*ep, kInetEvent_TCPConnectComplete,
static_cast<uintptr_t>(conErr.AsInteger())) != CHIP_NO_ERROR)
res = ERR_ABRT;
}
else
Expand Down Expand Up @@ -2269,7 +2270,8 @@ err_t TCPEndPoint::LwIPHandleIncomingConnection(void * arg, struct tcp_pcb * tpc
tcp_err(tpcb, LwIPHandleError);

// Post a callback to the HandleConnectionReceived() function, passing it the new end point.
if (lSystemLayer.PostEvent(*listenEP, kInetEvent_TCPConnectionReceived, (uintptr_t) conEP) != CHIP_NO_ERROR)
if (lSystemLayer.WatchableEventsManager().PostEvent(*listenEP, kInetEvent_TCPConnectionReceived, (uintptr_t) conEP) !=
CHIP_NO_ERROR)
{
err = CHIP_ERROR_CONNECTION_ABORTED;
conEP->Release(); // for the Retain() above
Expand All @@ -2279,7 +2281,8 @@ err_t TCPEndPoint::LwIPHandleIncomingConnection(void * arg, struct tcp_pcb * tpc

// Otherwise, there was an error accepting the connection, so post a callback to the HandleError function.
else
lSystemLayer.PostEvent(*listenEP, kInetEvent_TCPError, static_cast<uintptr_t>(err.AsInteger()));
lSystemLayer.WatchableEventsManager().PostEvent(*listenEP, kInetEvent_TCPError,
static_cast<uintptr_t>(err.AsInteger()));
}
else
err = CHIP_ERROR_CONNECTION_ABORTED;
Expand All @@ -2305,7 +2308,7 @@ err_t TCPEndPoint::LwIPHandleDataReceived(void * arg, struct tcp_pcb * tpcb, str
chip::System::Layer & lSystemLayer = ep->SystemLayer();

// Post callback to HandleDataReceived.
if (lSystemLayer.PostEvent(*ep, kInetEvent_TCPDataReceived, (uintptr_t) p) != CHIP_NO_ERROR)
if (lSystemLayer.WatchableEventsManager().PostEvent(*ep, kInetEvent_TCPDataReceived, (uintptr_t) p) != CHIP_NO_ERROR)
res = ERR_ABRT;
}
else
Expand All @@ -2327,7 +2330,7 @@ err_t TCPEndPoint::LwIPHandleDataSent(void * arg, struct tcp_pcb * tpcb, u16_t l
chip::System::Layer & lSystemLayer = ep->SystemLayer();

// Post callback to HandleDataReceived.
if (lSystemLayer.PostEvent(*ep, kInetEvent_TCPDataSent, (uintptr_t) len) != CHIP_NO_ERROR)
if (lSystemLayer.WatchableEventsManager().PostEvent(*ep, kInetEvent_TCPDataSent, (uintptr_t) len) != CHIP_NO_ERROR)
res = ERR_ABRT;
}
else
Expand Down Expand Up @@ -2356,7 +2359,7 @@ void TCPEndPoint::LwIPHandleError(void * arg, err_t lwipErr)

// Post callback to HandleError.
CHIP_ERROR err = chip::System::MapErrorLwIP(lwipErr);
lSystemLayer.PostEvent(*ep, kInetEvent_TCPError, static_cast<uintptr_t>(err.AsInteger()));
lSystemLayer.WatchableEventsManager().PostEvent(*ep, kInetEvent_TCPError, static_cast<uintptr_t>(err.AsInteger()));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/inet/UDPEndPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ CHIP_ERROR UDPEndPoint::Bind(IPAddressType addrType, const IPAddress & addr, uin
}

#if CHIP_SYSTEM_CONFIG_USE_DISPATCH
dispatch_queue_t dispatchQueue = SystemLayer().GetDispatchQueue();
dispatch_queue_t dispatchQueue = SystemLayer().WatchableEventsManager().GetDispatchQueue();
if (dispatchQueue != nullptr)
{
unsigned long fd = static_cast<unsigned long>(mSocket.GetFD());
Expand Down
10 changes: 5 additions & 5 deletions src/inet/tests/TestInetCommonPosix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,9 +455,9 @@ void ServiceEvents(struct ::timeval & aSleepTime)
}

#if CHIP_SYSTEM_CONFIG_USE_SOCKETS
gSystemLayer.WatchableEvents().PrepareEventsWithTimeout(aSleepTime);
gSystemLayer.WatchableEvents().WaitForEvents();
gSystemLayer.WatchableEvents().HandleEvents();
gSystemLayer.WatchableEventsManager().PrepareEventsWithTimeout(aSleepTime);
gSystemLayer.WatchableEventsManager().WaitForEvents();
gSystemLayer.WatchableEventsManager().HandleEvents();
#endif // CHIP_SYSTEM_CONFIG_USE_SOCKETS

#if CHIP_SYSTEM_CONFIG_USE_LWIP
Expand All @@ -469,7 +469,7 @@ void ServiceEvents(struct ::timeval & aSleepTime)
{
if (sRemainingSystemLayerEventDelay == 0)
{
gSystemLayer.DispatchEvents();
gSystemLayer.WatchableEventsManager().DispatchEvents();
sRemainingSystemLayerEventDelay = gNetworkOptions.EventDelay;
}
else
Expand All @@ -478,7 +478,7 @@ void ServiceEvents(struct ::timeval & aSleepTime)
// TODO: Currently timers are delayed by aSleepTime above. A improved solution would have a mechanism to reduce
// aSleepTime according to the next timer.

gSystemLayer.HandlePlatformTimer();
gSystemLayer.WatchableEventsManager().HandlePlatformTimer();
}
}
#if CHIP_TARGET_STYLE_UNIX
Expand Down
1 change: 0 additions & 1 deletion src/platform/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ if (chip_device_platform != "none") {
"LockTracker.cpp",
"PersistedStorage.cpp",
"SystemEventSupport.cpp",
"SystemTimerSupport.cpp",
"TestIdentity.cpp",
]

Expand Down
2 changes: 1 addition & 1 deletion src/platform/Darwin/PlatformManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack()
err = Internal::GenericPlatformManagerImpl<PlatformManagerImpl>::_InitChipStack();
SuccessOrExit(err);

SystemLayer.SetDispatchQueue(GetWorkQueue());
SystemLayer.WatchableEventsManager().SetDispatchQueue(GetWorkQueue());

exit:
return err;
Expand Down
Loading

0 comments on commit 2d103c8

Please sign in to comment.