00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef THREAD_H
00033 #define THREAD_H
00034
00035 #include "openjpeg.h"
00036
00047
00050
00052 typedef struct opj_mutex_t opj_mutex_t;
00053
00058 opj_mutex_t* opj_mutex_create(void);
00059
00063 void opj_mutex_lock(opj_mutex_t* mutex);
00064
00068 void opj_mutex_unlock(opj_mutex_t* mutex);
00069
00073 void opj_mutex_destroy(opj_mutex_t* mutex);
00074
00079
00081 typedef struct opj_cond_t opj_cond_t;
00082
00087 opj_cond_t* opj_cond_create(void);
00088
00120 void opj_cond_wait(opj_cond_t* cond, opj_mutex_t* mutex);
00121
00128 void opj_cond_signal(opj_cond_t* cond);
00129
00133 void opj_cond_destroy(opj_cond_t* cond);
00134
00139
00141 typedef struct opj_thread_t opj_thread_t;
00142
00146 typedef void (*opj_thread_fn)(void* user_data);
00147
00154 opj_thread_t* opj_thread_create(opj_thread_fn thread_fn, void* user_data);
00155
00160 void opj_thread_join(opj_thread_t* thread);
00161
00167 typedef struct opj_tls_t opj_tls_t;
00168
00174 void* opj_tls_get(opj_tls_t* tls, int key);
00175
00177 typedef void (*opj_tls_free_func)(void* value);
00178
00186 OPJ_BOOL opj_tls_set(opj_tls_t* tls, int key, void* value,
00187 opj_tls_free_func free_func);
00188
00193
00195 typedef struct opj_thread_pool_t opj_thread_pool_t;
00196
00207 opj_thread_pool_t* opj_thread_pool_create(int num_threads);
00208
00213 typedef void (*opj_job_fn)(void* user_data, opj_tls_t* tls);
00214
00215
00225 OPJ_BOOL opj_thread_pool_submit_job(opj_thread_pool_t* tp, opj_job_fn job_fn,
00226 void* user_data);
00227
00237 void opj_thread_pool_wait_completion(opj_thread_pool_t* tp,
00238 int max_remaining_jobs);
00239
00245 int opj_thread_pool_get_thread_count(opj_thread_pool_t* tp);
00246
00250 void opj_thread_pool_destroy(opj_thread_pool_t* tp);
00251
00255
00256 #endif