Less bonkers
This commit is contained in:
parent
e0f16d8c3c
commit
80cc0f663d
2 changed files with 6 additions and 8 deletions
|
@ -19,7 +19,7 @@ typedef struct _hexagram_schedule_table_entry {
|
||||||
|
|
||||||
typedef struct _hexagram_schedule_slot {
|
typedef struct _hexagram_schedule_slot {
|
||||||
time_t interval_us;
|
time_t interval_us;
|
||||||
hexagram_schedule_handler handler;
|
hexagram_schedule_table_entry *entry;
|
||||||
} hexagram_schedule_slot;
|
} hexagram_schedule_slot;
|
||||||
|
|
||||||
typedef struct _hexagram_schedule {
|
typedef struct _hexagram_schedule {
|
||||||
|
|
|
@ -40,10 +40,10 @@ static void _ev_notify(union sigval sv) {
|
||||||
|
|
||||||
while (schedule->current < schedule->count) {
|
while (schedule->current < schedule->count) {
|
||||||
hexagram_schedule_slot *slot = _slot(schedule, schedule->current);
|
hexagram_schedule_slot *slot = _slot(schedule, schedule->current);
|
||||||
|
hexagram_schedule_table_entry *entry = slot->entry;
|
||||||
time_t delay = slot->interval_us;
|
time_t delay = slot->interval_us;
|
||||||
|
|
||||||
if (slot->handler(&(schedule->table[schedule->current].frame),
|
if (entry->handler(&entry->frame, schedule->ctx) < 0) {
|
||||||
schedule->ctx) < 0) {
|
|
||||||
schedule->error = errno;
|
schedule->error = errno;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -83,17 +83,15 @@ static int _schedule_init(hexagram_schedule *schedule,
|
||||||
schedule->ev.sigev_notify_function = _ev_notify;
|
schedule->ev.sigev_notify_function = _ev_notify;
|
||||||
schedule->ev.sigev_value.sival_ptr = schedule;
|
schedule->ev.sigev_value.sival_ptr = schedule;
|
||||||
|
|
||||||
if (timer_create(CLOCK_REALTIME,
|
if (timer_create(CLOCK_REALTIME, &schedule->ev, &schedule->timer) < 0) {
|
||||||
&schedule->ev,
|
|
||||||
&schedule->timer) < 0) {
|
|
||||||
goto error_timer_create;
|
goto error_timer_create;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0; i<count; i++) {
|
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->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);
|
qsort(schedule + 1, count, sizeof(hexagram_schedule_slot), _slot_cmp);
|
||||||
|
|
Loading…
Add table
Reference in a new issue