3#include <clod/structures/table.h>
12 bool (*task_func)(
void *user);
16#define PERIOD_US (200 * 1000)
18int daemon_run(
int,
char **) {
20 assert(!daemon_table);
26 while (empty_loops++ < 5) {
28 int64_t current =
clod_timer(&time, PERIOD_US);
30 if (current > time) time = current;
37 bool res =
task->task_func(
task->user);
40 if (res) free(
clod_table_del(daemon_table, iter.element, iter.key_size));
48 daemon_table =
nullptr;
53void clod_daemon_add(
const uintptr_t
id,
bool (*task_func)(
void *user),
void *user) {
64 fprintf(stderr,
"Failed to start libclod daemon");
78 task->task_func = task_func;
84 task->task_func = task_func;
92void clod_daemon_del(
const uintptr_t
id) {
95 if (daemon_table !=
nullptr) {
99 if (
task->counter == 0)
size_t clod_table_len(const struct clod_table *t)
void clod_table_destroy(struct clod_table *t)
bool clod_table_iter(const struct clod_table *t, struct clod_table_iter *iter)
struct clod_table * clod_table_create(const struct clod_table_opts *opts)
bool clod_table_add(struct clod_table *t, const void *element, size_t key_size, void **existing_out)
void * clod_table_get(const struct clod_table *t, const void *key, size_t key_size)
void * clod_table_del(struct clod_table *t, const void *key, size_t key_size)
int64_t clod_timer(int64_t *time, int64_t duration_us)
void clod_spinlock_lock(clod_spinlock *spinlock)
void clod_spinlock_unlock(clod_spinlock *spinlock)
enum clod_process_result clod_process_start(struct clod_process_opts *opts, clod_process *process_out)