Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit 122d434

Browse files
add ScheduleRun in NE
-- DataManagement Update Server needs to send notify to client when subscription is there. In order to decrease the stack depth, add ScheduleRun in NotificationEngine to achieve async notificaiton engine run.
1 parent 5c933cd commit 122d434

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/lib/profiles/data-management/Current/NotificationEngine.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
22
*
3-
* Copyright (c) 2016-2017 Nest Labs, Inc.
3+
* Copyright (c) 2016-2018 Nest Labs, Inc.
4+
* Copyright (c) 2019 Google, LLC.
45
* All rights reserved.
56
*
67
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -1701,6 +1702,17 @@ WEAVE_ERROR NotificationEngine::BuildSubscriptionlessNotification(PacketBuffer *
17011702

17021703
#endif // WDM_ENABLE_SUBSCRIPTIONLESS_NOTIFICATION
17031704

1705+
void NotificationEngine::Run(System::Layer * aSystemLayer, void * aAppState, System::Error)
1706+
{
1707+
NotificationEngine * const pEngine = reinterpret_cast<NotificationEngine *>(aAppState);
1708+
pEngine->Run();
1709+
}
1710+
1711+
void NotificationEngine::ScheduleRun()
1712+
{
1713+
SubscriptionEngine::GetInstance()->GetExchangeManager()->MessageLayer->SystemLayer->ScheduleWork(Run, this);
1714+
}
1715+
17041716
void NotificationEngine::Run()
17051717
{
17061718
WEAVE_ERROR err = WEAVE_NO_ERROR;

src/lib/profiles/data-management/Current/NotificationEngine.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
22
*
3-
* Copyright (c) 2016-2017 Nest Labs, Inc.
3+
* Copyright (c) 2016-2018 Nest Labs, Inc.
4+
* Copyright (c) 2019 Google, LLC.
45
* All rights reserved.
56
*
67
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -114,6 +115,11 @@ class NotificationEngine
114115
*/
115116
void Run(void);
116117

118+
/**
119+
* Main work-horse function that executes the run-loop asynchronously on the Weave thread
120+
*/
121+
void ScheduleRun(void);
122+
117123
/**
118124
* Marks a handle associated with a data source as being dirty.
119125
*
@@ -394,6 +400,8 @@ class NotificationEngine
394400

395401
WEAVE_ERROR SendNotifyRequest();
396402

403+
static void Run(System::Layer * aSystemLayer, void * aAppState, System::Error);
404+
397405
#if WDM_ENABLE_SUBSCRIPTIONLESS_NOTIFICATION
398406
WEAVE_ERROR BuildSubscriptionlessNotification(PacketBuffer *msgBuf, uint32_t maxPayloadSize, TraitPath *aPathList,
399407
uint16_t aPathListSize);

0 commit comments

Comments
 (0)