Loading automotive/remoteaccess/test_grpc_server/impl/include/TestWakeupClientServiceImpl.h +3 −2 Original line number Diff line number Diff line Loading @@ -78,6 +78,7 @@ class TaskQueue final { void waitForTask(); void stopWait(); bool isEmpty(); bool isStopped(); private: friend class TaskTimeoutMessageHandler; Loading @@ -87,7 +88,7 @@ class TaskQueue final { GUARDED_BY(mLock); // A variable to notify mTasks is not empty. std::condition_variable mTasksNotEmptyCv; std::atomic<bool> mStopped; std::atomic<bool> mStopped = false; android::sp<Looper> mLooper; android::sp<TaskTimeoutMessageHandler> mTaskTimeoutMessageHandler; std::atomic<int> mTaskIdCounter = 0; Loading Loading @@ -214,7 +215,7 @@ class TestWakeupClientServiceImpl : public WakeupClient::Service { std::atomic<bool> mRemoteTaskConnectionAlive = false; std::mutex mLock; bool mGeneratingFakeTask GUARDED_BY(mLock); std::atomic<bool> mServerStopped; std::atomic<bool> mServerStopped = false; std::unordered_map<std::string, std::unordered_map<std::string, ScheduleInfo>> mInfoByScheduleIdByClientId GUARDED_BY(mLock); Loading automotive/remoteaccess/test_grpc_server/impl/src/TestWakeupClientServiceImpl.cpp +7 −1 Original line number Diff line number Diff line Loading @@ -105,6 +105,10 @@ void TaskQueue::waitForTask() { }); } bool TaskQueue::isStopped() { return mStopped; } void TaskQueue::stopWait() { mStopped = true; { Loading Loading @@ -241,7 +245,7 @@ Status TestWakeupClientServiceImpl::GetRemoteTasks(ServerContext* context, while (true) { mTaskQueue->waitForTask(); if (mServerStopped) { if (mTaskQueue->isStopped()) { // Server stopped, exit the loop. printf("Server stopped exit loop\n"); break; Loading @@ -250,11 +254,13 @@ Status TestWakeupClientServiceImpl::GetRemoteTasks(ServerContext* context, while (true) { auto maybeTask = mTaskQueue->maybePopOne(); if (!maybeTask.has_value()) { printf("no task left\n"); // No task left, loop again and wait for another task(s). break; } // Loop through all the task in the queue but obtain lock for each element so we don't // hold lock while writing the response. printf("Sending one remote task\n"); const GetRemoteTasksResponse& response = maybeTask.value(); if (!writer->Write(response)) { // Broken stream, maybe the client is shutting down. Loading Loading
automotive/remoteaccess/test_grpc_server/impl/include/TestWakeupClientServiceImpl.h +3 −2 Original line number Diff line number Diff line Loading @@ -78,6 +78,7 @@ class TaskQueue final { void waitForTask(); void stopWait(); bool isEmpty(); bool isStopped(); private: friend class TaskTimeoutMessageHandler; Loading @@ -87,7 +88,7 @@ class TaskQueue final { GUARDED_BY(mLock); // A variable to notify mTasks is not empty. std::condition_variable mTasksNotEmptyCv; std::atomic<bool> mStopped; std::atomic<bool> mStopped = false; android::sp<Looper> mLooper; android::sp<TaskTimeoutMessageHandler> mTaskTimeoutMessageHandler; std::atomic<int> mTaskIdCounter = 0; Loading Loading @@ -214,7 +215,7 @@ class TestWakeupClientServiceImpl : public WakeupClient::Service { std::atomic<bool> mRemoteTaskConnectionAlive = false; std::mutex mLock; bool mGeneratingFakeTask GUARDED_BY(mLock); std::atomic<bool> mServerStopped; std::atomic<bool> mServerStopped = false; std::unordered_map<std::string, std::unordered_map<std::string, ScheduleInfo>> mInfoByScheduleIdByClientId GUARDED_BY(mLock); Loading
automotive/remoteaccess/test_grpc_server/impl/src/TestWakeupClientServiceImpl.cpp +7 −1 Original line number Diff line number Diff line Loading @@ -105,6 +105,10 @@ void TaskQueue::waitForTask() { }); } bool TaskQueue::isStopped() { return mStopped; } void TaskQueue::stopWait() { mStopped = true; { Loading Loading @@ -241,7 +245,7 @@ Status TestWakeupClientServiceImpl::GetRemoteTasks(ServerContext* context, while (true) { mTaskQueue->waitForTask(); if (mServerStopped) { if (mTaskQueue->isStopped()) { // Server stopped, exit the loop. printf("Server stopped exit loop\n"); break; Loading @@ -250,11 +254,13 @@ Status TestWakeupClientServiceImpl::GetRemoteTasks(ServerContext* context, while (true) { auto maybeTask = mTaskQueue->maybePopOne(); if (!maybeTask.has_value()) { printf("no task left\n"); // No task left, loop again and wait for another task(s). break; } // Loop through all the task in the queue but obtain lock for each element so we don't // hold lock while writing the response. printf("Sending one remote task\n"); const GetRemoteTasksResponse& response = maybeTask.value(); if (!writer->Write(response)) { // Broken stream, maybe the client is shutting down. Loading