mirror of
https://gitee.com/openharmony/drivers_framework
synced 2024-11-23 21:10:02 +00:00
fix: optimization of hdf message looper exit mechanism
Signed-off-by: baoguotao <baoguotao@huawei.com>
This commit is contained in:
parent
d8470f621d
commit
cbeb44b164
@ -21,6 +21,7 @@ struct HdfMessageLooper {
|
|||||||
struct HdfMessageQueue messageQueue;
|
struct HdfMessageQueue messageQueue;
|
||||||
void (*Start)(struct HdfMessageLooper *);
|
void (*Start)(struct HdfMessageLooper *);
|
||||||
void (*Stop)(struct HdfMessageLooper *);
|
void (*Stop)(struct HdfMessageLooper *);
|
||||||
|
bool isRunning;
|
||||||
};
|
};
|
||||||
|
|
||||||
void HdfMessageLooperConstruct(struct HdfMessageLooper *looper);
|
void HdfMessageLooperConstruct(struct HdfMessageLooper *looper);
|
||||||
|
@ -13,12 +13,17 @@
|
|||||||
void HdfMessageLooperStart(struct HdfMessageLooper *looper)
|
void HdfMessageLooperStart(struct HdfMessageLooper *looper)
|
||||||
{
|
{
|
||||||
struct HdfMessage *message = NULL;
|
struct HdfMessage *message = NULL;
|
||||||
while (looper != NULL) {
|
if (looper == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
looper->isRunning = true;
|
||||||
|
while (true) {
|
||||||
message = HdfMessageQueueNext(&looper->messageQueue);
|
message = HdfMessageQueueNext(&looper->messageQueue);
|
||||||
if (message != NULL) {
|
if (message != NULL) {
|
||||||
if (message->messageId == MESSAGE_STOP_LOOP) {
|
if (message->messageId == MESSAGE_STOP_LOOP) {
|
||||||
HdfMessageRecycle(message);
|
HdfMessageRecycle(message);
|
||||||
OsalMessageQueueDestroy(&looper->messageQueue);
|
OsalMessageQueueDestroy(&looper->messageQueue);
|
||||||
|
looper->isRunning = false;
|
||||||
break;
|
break;
|
||||||
} else if (message->target != NULL) {
|
} else if (message->target != NULL) {
|
||||||
struct HdfMessageTask *task = message->target;
|
struct HdfMessageTask *task = message->target;
|
||||||
@ -31,7 +36,7 @@ void HdfMessageLooperStart(struct HdfMessageLooper *looper)
|
|||||||
|
|
||||||
void HdfMessageLooperStop(struct HdfMessageLooper *looper)
|
void HdfMessageLooperStop(struct HdfMessageLooper *looper)
|
||||||
{
|
{
|
||||||
if (looper == NULL) {
|
if (looper == NULL || !looper->isRunning) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user