* 3. Perform the event's callback.
* 4. Schedule next event planned event.
*/
-static void event_wrap(task_t *task)
+static void event_wrap(worker_task_t *task)
{
assert(task);
assert(task->ctx);
event_t *event; //!< Scheduler event.
worker_pool_t *pool; //!< Server worker pool.
- task_t task; //!< Event execution context.
+ worker_task_t task; //!< Event execution context.
time_t time[ZONE_EVENT_COUNT]; //!< Event execution times.
bool forced[ZONE_EVENT_COUNT]; //!< Flag that the event was invoked by user ctl.
pthread_cond_t *blocking[ZONE_EVENT_COUNT]; //!< For blocking events: dispatching cond.
break;
}
- task_t *task = NULL;
+ worker_task_t *task = NULL;
if (!pool->suspended) {
task = worker_queue_dequeue(&pool->tasks);
}
-/* Copyright (C) 2019 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+/* Copyright (C) 2021 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
ptrlist_free(&queue->list, &queue->mm_ctx);
}
-void worker_queue_enqueue(worker_queue_t *queue, task_t *task)
+void worker_queue_enqueue(worker_queue_t *queue, worker_task_t *task)
{
if (!queue || !task) {
return;
ptrlist_add(&queue->list, task, &queue->mm_ctx);
}
-task_t *worker_queue_dequeue(worker_queue_t *queue)
+worker_task_t *worker_queue_dequeue(worker_queue_t *queue)
{
if (!queue) {
return NULL;
}
- task_t *task = NULL;
+ worker_task_t *task = NULL;
if (!EMPTY_LIST(queue->list)) {
ptrnode_t *node = HEAD(queue->list);
-/* Copyright (C) 2019 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+/* Copyright (C) 2021 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
typedef struct task {
void *ctx;
task_cb run;
-} task_t;
+} worker_task_t;
/*!
* \brief Worker queue.
/*!
* \brief Insert new item into the queue.
*/
-void worker_queue_enqueue(worker_queue_t *queue, task_t *task);
+void worker_queue_enqueue(worker_queue_t *queue, worker_task_t *task);
/*!
* \brief Remove item from the queue.
*
* \return Task or NULL if the queue is empty.
*/
-task_t *worker_queue_dequeue(worker_queue_t *queue);
+worker_task_t *worker_queue_dequeue(worker_queue_t *queue);
/*!
* \brief Return number of tasks in worker queue.
-/* Copyright (C) 2014 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+/* Copyright (C) 2021 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
/*!
* Simple task, just increases the counter in the log.
*/
-static void task_counting(task_t *task)
+static void task_counting(worker_task_t *task)
{
task_log_t *log = task->ctx;
// schedule jobs while pool is stopped
- task_t task = { .run = task_counting, .ctx = &log };
+ worker_task_t task = { .run = task_counting, .ctx = &log };
for (int i = 0; i < TASKS_BATCH; i++) {
worker_pool_assign(pool, &task);
}
-/* Copyright (C) 2014 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+/* Copyright (C) 2021 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
{
plan_lazy();
- task_t task_one = { 0 };
- task_t task_two = { 0 };
- task_t task_three = { 0 };
+ worker_task_t task_one = { 0 };
+ worker_task_t task_two = { 0 };
+ worker_task_t task_three = { 0 };
// init