File: threadpool.h

package info (click to toggle)
kvmtool 0.20161128-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,748 kB
  • ctags: 6,310
  • sloc: ansic: 25,215; makefile: 495; asm: 212; sh: 122
file content (38 lines) | stat: -rw-r--r-- 773 bytes parent folder | download
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
37
38
#ifndef KVM__THREADPOOL_H
#define KVM__THREADPOOL_H

#include "kvm/mutex.h"

#include <linux/list.h>

struct kvm;

typedef void (*kvm_thread_callback_fn_t)(struct kvm *kvm, void *data);

struct thread_pool__job {
	kvm_thread_callback_fn_t	callback;
	struct kvm			*kvm;
	void				*data;

	int				signalcount;
	struct mutex			mutex;

	struct list_head		queue;
};

static inline void thread_pool__init_job(struct thread_pool__job *job, struct kvm *kvm, kvm_thread_callback_fn_t callback, void *data)
{
	*job = (struct thread_pool__job) {
		.kvm		= kvm,
		.callback	= callback,
		.data		= data,
		.mutex		= MUTEX_INITIALIZER,
	};
}

int thread_pool__init(struct kvm *kvm);
int thread_pool__exit(struct kvm *kvm);

void thread_pool__do_job(struct thread_pool__job *job);

#endif