-
Notifications
You must be signed in to change notification settings - Fork 8
/
workqueue.h
36 lines (27 loc) · 725 Bytes
/
workqueue.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#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