/** The point of the grab client's node in the buffer tree. */
struct btr_node *btrn;
/* The task of this grab client. */
- struct task task;
+ struct task *task;
/** Belongs to either the active or the inactive list. */
struct list_head node;
};
static void gc_pre_select(struct sched *s, struct task *t)
{
- struct grab_client *gc = container_of(t, struct grab_client, task);
+ struct grab_client *gc = task_context(t);
int ret = btr_node_status(gc->btrn, 0, BTR_NT_LEAF);
if (ret == 0)
list_move(&gc->node, &active_grab_client_list);
gc->btrn = btr_new_node(&(struct btr_node_description)
EMBRACE(.name = name, .parent = parent));
- gc->task.pre_select = gc_pre_select;
- gc->task.post_select = gc_post_select;
- snprintf(gc->task.status, sizeof(gc->task.status) - 1, "%s", name);
- gc->task.status[sizeof(gc->task.status) - 1] = '\0';
- gc->task.error = 0;
- register_task(s, &gc->task);
+
+ gc->task = task_register(&(struct task_info) {
+ .name = name,
+ .pre_select = gc_pre_select,
+ .post_select = gc_post_select,
+ .context = gc,
+ }, s);
}
/**
static int gc_post_select(__a_unused struct sched *s, struct task *t)
{
- struct grab_client *gc = container_of(t, struct grab_client, task);
+ struct grab_client *gc = task_context(t);
struct btr_node *btrn = gc->btrn;
int ret;
size_t sz;