shoreline/workqueue.h
Tobias Schramm 33a8de08e5 Add numa node-local workqueues
Using numa node-local workqueues we can safely reallocate memory on framebuffers without
risk of destroying node-locality of the reallocated memory
2018-09-15 14:19:05 +02:00

36 lines
725 B
C

#ifndef _WORKQUEUE_H_
#define _WORKQUEUE_H_
#include <pthread.h>
#include <stdbool.h>
#include "llist.h"
typedef int (*wqueue_cb)(void* priv);
typedef int (*wqueue_err)(int err, void* priv);
typedef void (*wqueue_cleanup)(int err, void* priv);
struct workqueue_entry {
int (*cb)(void* priv);
int (*err)(int err, void* priv);
void (*cleanup)(int err, void* priv);
void* priv;
struct llist_entry list;
};
struct workqueue {
struct llist entries;
unsigned numa_node;
bool do_exit;
pthread_t thread;
pthread_cond_t cond;
pthread_mutex_t lock;
};
int workqueue_init();
void workqueue_deinit();
int workqueue_enqueue(unsigned numa_node, void* priv, wqueue_cb cb, wqueue_err err, wqueue_cleanup cleanup);
#endif