Skip to content

Commit 0ea42c4

Browse files
committed
Fix timer bug, remove unused comments
1 parent 7e13df1 commit 0ea42c4

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

examples/chef/common/chef-rpc-actions-worker.cpp

+8-7
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
#include <platform/CHIPDeviceLayer.h>
2626
#include <map>
2727

28-
//#include <Actions.h>
29-
3028
using chip::app::DataModel::Nullable;
3129

3230
using namespace chip;
@@ -65,9 +63,11 @@ bool ChefRpcActionsWorker::EnqueueAction(ActionTask task)
6563
bool kickTimer = false;
6664

6765
if (queue.empty()) {
68-
queue.push(task);
6966
kickTimer = true; // kick timer when the first task is adding to the queue
7067
}
68+
69+
queue.push(task);
70+
7171
if (kickTimer) {
7272
(void) DeviceLayer::SystemLayer().StartTimer(System::Clock::Milliseconds32(task.delayMs), RpcActionsTaskCallback, this);
7373
}
@@ -76,7 +76,7 @@ bool ChefRpcActionsWorker::EnqueueAction(ActionTask task)
7676

7777
void ChefRpcActionsWorker::ProcessActionQueue()
7878
{
79-
// delete queue;
79+
// Dequeue the first item
8080
ActionTask task = queue.front();
8181
queue.pop();
8282

@@ -113,22 +113,23 @@ printf("\033[41m %s , %d, Emitting Event: %d, args size=%lu \033[0m \n", __func_
113113
}
114114

115115
if (queue.empty()) {
116-
// Return due to no extra queue item to run.
116+
// Return due to no more actions in queue
117117
return;
118118
}
119119

120-
// Run next task
120+
// Run next action
121121
task = queue.front();
122+
printf("\033[44m %s , %d, next action: endpointId=%d, clusterId=%d, delayMs=%d \033[0m \n", __func__, __LINE__, task.endpointId, task.clusterId, task.delayMs);
122123
(void) DeviceLayer::SystemLayer().StartTimer(System::Clock::Milliseconds32(task.delayMs), RpcActionsTaskCallback, this);
123124
}
124125

125126
void ChefRpcActionsWorker::RegisterRpcActionsDelegate(ClusterId clusterId, ActionsDelegate * delegate)
126127
{
128+
// Register by cluster
127129
if ( nullptr == RpcFindActionsDelegate(clusterId) ) {
128130
gActionsDelegateMap[clusterId] = delegate;
129131
return;
130132
}
131-
// TBD: print already registered
132133
}
133134

134135
ChefRpcActionsWorker::ChefRpcActionsWorker()

examples/platform/linux/Rpc.h

-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@
1818

1919
#pragma once
2020

21-
// #if defined(PW_RPC_ACTIONS_SERVICE) && PW_RPC_ACTIONS_SERVICE
22-
// #include "../../common/pigweed/rpc_services/Actions.h"
23-
// #endif // defined(PW_RPC_ACTIONS_SERVICE) && PW_RPC_ACTIONS_SERVICE
24-
2521
#include <vector>
2622
#include <queue>
2723

0 commit comments

Comments
 (0)