diff options
Diffstat (limited to 'src/schedule.c')
-rw-r--r-- | src/schedule.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/schedule.c b/src/schedule.c index e69de29..e746a7f 100644 --- a/src/schedule.c +++ b/src/schedule.c @@ -0,0 +1,36 @@ +// Copyright (c) 2023, Marvin Borner <dev@marvinborner.de> +// SPDX-License-Identifier: MIT + +#include <schedule.h> +#include <lib/pqueue.h> +#include <parse.h> +#include <map.h> + +static struct pqueue *queue; + +static pqueue_pri_t get_pri(void *a) +{ + struct term *term = a; + return (parse_get_max_depth() - term->depth + 1) * term->refs; +} + +static int cmp_pri(pqueue_pri_t next, pqueue_pri_t curr) +{ + return next < curr; +} + +static void set_pos(void *a, size_t position) +{ + (void)a; + (void)position; +} + +void schedule_init(void) +{ + queue = map_to_pqueue(cmp_pri, get_pri, set_pos); +} + +void schedule_destroy(void) +{ + pqueue_free(queue); +} |