1 /* 2 * Copyright (c) 2020-2021 Huawei Device Co., Ltd. 3 * 4 * HDF is dual licensed: you can use it either under the terms of 5 * the GPL, or the BSD license, at your option. 6 * See the LICENSE file in the root of this repository for complete details. 7 */ 8 9 #ifndef HDF_MESSAGE_TASK_H 10 #define HDF_MESSAGE_TASK_H 11 12 #include "hdf_message_looper.h" 13 #include "osal_msg_queue.h" 14 15 #ifdef __cplusplus 16 extern "C" { 17 #endif /* __cplusplus */ 18 19 struct HdfMessageTask; 20 21 struct IHdfMessageHandler { 22 int32_t (*Dispatch)(struct HdfMessageTask *task, struct HdfMessage *msg); 23 }; 24 25 struct HdfMessageTask { 26 int32_t (*SendMessage)(struct HdfMessageTask *task, struct HdfMessage *msg, bool sync); 27 void (*RemoveMessage)(struct HdfMessageTask *task, struct HdfMessage *msg); 28 void (*SendMessageLater)(struct HdfMessageTask *task, struct HdfMessage *msg, long delay); 29 void (*DispatchMessage)(struct HdfMessageTask *task, struct HdfMessage *msg); 30 struct HdfMessageQueue *messageQueue; 31 struct IHdfMessageHandler *messageHandler; 32 }; 33 34 void HdfMessageTaskConstruct(struct HdfMessageTask *inst, 35 struct HdfMessageLooper *looper, struct IHdfMessageHandler *handler); 36 37 #ifdef __cplusplus 38 } 39 #endif /* __cplusplus */ 40 41 #endif /* HDF_MESSAGE_TASK_H */ 42