* Copyright (c) 2025-2026 IB-Robot Group & openEuler Embedded SIG & openharmony-robot sig_RoboFrame.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <stddef.h>
#include <stdbool.h>
#include <stdint.h>
#include "c/util/function_base.h"
#include "c/util/string.h"
#ifdef __cplusplus
extern "C" {
#endif
* @brief Operate struct for executor task
* @note
* Signature: void(*)()
*/
typedef struct {
void (*invoker)(void* object);
void (*relocator)(void* from, void* to);
void (*destroyer)(void* object);
} ibmw_function_executor_task_ops_t;
* @brief Executor interface
*
*/
typedef struct {
* @brief Size of this table in bytes (sizeof of the provider's struct).
* Must be the first field. Consumers reject a table smaller than the
* struct they were compiled against.
*/
size_t struct_size;
ibmw_string_view_t (*type)(void* ctx);
ibmw_string_view_t (*name)(void* ctx);
bool (*is_thread_safe)(void* ctx);
bool (*is_in_current_executor)(void* ctx);
bool (*supports_timed_dispatch)(void* ctx);
* @brief Function to execute task
* @note
* Input 1: Implement pointer to executor handle
* Input 2: Task, which ops type is 'ibmw_function_executor_task_ops_t'
*/
void (*dispatch)(void* ctx, ibmw_function_base_t* task);
* @brief Function to get current timestamp
* @note
* Input 1: Implement pointer to executor handle
* Output: Current nanosecond timestamp, since 1970-01-01 00:00:00 UTC
*/
uint64_t (*now)(void* ctx);
* @brief Function to execute task at a time point
* @note
* Input 1: Implement pointer to executor handle
* Input 2: Timestamp, nanosecond since 1970-01-01 00:00:00 UTC
* Input 3: Task, which ops type is 'ibmw_function_executor_task_ops_t'
*/
void (*dispatch_at_ns)(void* ctx, uint64_t tp, ibmw_function_base_t* task);
void* ctx;
} ibmw_executor_base_t;
#ifdef __cplusplus
}
#endif