Less bonkers

This commit is contained in:
XANTRONIX 2023-12-27 14:13:00 -05:00
parent e0f16d8c3c
commit 80cc0f663d
2 changed files with 6 additions and 8 deletions

View file

@ -19,7 +19,7 @@ typedef struct _hexagram_schedule_table_entry {
typedef struct _hexagram_schedule_slot {
time_t interval_us;
hexagram_schedule_handler handler;
hexagram_schedule_table_entry *entry;
} hexagram_schedule_slot;
typedef struct _hexagram_schedule {

View file

@ -40,10 +40,10 @@ static void _ev_notify(union sigval sv) {
while (schedule->current < schedule->count) {
hexagram_schedule_slot *slot = _slot(schedule, schedule->current);
hexagram_schedule_table_entry *entry = slot->entry;
time_t delay = slot->interval_us;
if (slot->handler(&(schedule->table[schedule->current].frame),
schedule->ctx) < 0) {
if (entry->handler(&entry->frame, schedule->ctx) < 0) {
schedule->error = errno;
break;
@ -83,17 +83,15 @@ static int _schedule_init(hexagram_schedule *schedule,
schedule->ev.sigev_notify_function = _ev_notify;
schedule->ev.sigev_value.sival_ptr = schedule;
if (timer_create(CLOCK_REALTIME,
&schedule->ev,
&schedule->timer) < 0) {
if (timer_create(CLOCK_REALTIME, &schedule->ev, &schedule->timer) < 0) {
goto error_timer_create;
}
for (i=0; i<count; i++) {
hexagram_schedule_slot *slot = &((hexagram_schedule_slot *)(schedule + 1))[i];
hexagram_schedule_slot *slot = _slot(schedule, i);
slot->interval_us = table[i].interval_us;
slot->handler = table[i].handler;
slot->entry = &table[i];
}
qsort(schedule + 1, count, sizeof(hexagram_schedule_slot), _slot_cmp);