refactor(core/policy): 从 policy_context_t 中提取 event 为独立参数
policy_context_t 应该只包含所有 policy 相关接口都需要用到的参数,而 event 只是 policy_route_event 接口需要的参数,故应该将其从 policy_context_t 中剔除
This commit is contained in:
@@ -110,6 +110,11 @@ void runtime_run(runtime_t *runtime) {
|
||||
command_buffer_t *command_buffer = &runtime->command_buffer;
|
||||
plan_t *plan = &runtime->plan;
|
||||
|
||||
policy_context_t ctx = {
|
||||
.state = &runtime->state,
|
||||
.rules = &runtime->rules,
|
||||
};
|
||||
|
||||
while (runtime->running) {
|
||||
event_t event = {0};
|
||||
if (!backend_next_event(backend, &event)) break;
|
||||
@@ -117,13 +122,7 @@ void runtime_run(runtime_t *runtime) {
|
||||
command_buffer_reset(command_buffer);
|
||||
plan_reset(plan);
|
||||
|
||||
policy_context_t ctx = {
|
||||
.state = &runtime->state,
|
||||
.rules = &runtime->rules,
|
||||
.event = &event,
|
||||
};
|
||||
|
||||
policy_route_event(&ctx, command_buffer);
|
||||
policy_route_event(&ctx, &event, command_buffer);
|
||||
policy_apply_command(&ctx, command_buffer, plan);
|
||||
if (plan->count) backend_apply_effect(backend, plan->effects, plan->count);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user