mirror of
https://github.com/clearlinux/kvmtool.git
synced 2026-06-16 02:15:47 +00:00
df0c7f571e
To allow efficient use of shorter-term threadpool jobs, don't allocate them dynamically upon creation. Instead, store them within 'job' structures. This will prevent some overhead creating/destroying jobs which live for a short time. Signed-off-by: Sasha Levin <levinsasha928@gmail.com> Signed-off-by: Pekka Enberg <penberg@kernel.org>
38 lines
755 B
C
38 lines
755 B
C
#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;
|
|
pthread_mutex_t 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 = PTHREAD_MUTEX_INITIALIZER,
|
|
};
|
|
}
|
|
|
|
int thread_pool__init(unsigned long thread_count);
|
|
|
|
void thread_pool__do_job(struct thread_pool__job *job);
|
|
|
|
#endif
|