00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef MICROFEED_THREADS_H
00021 #define MICROFEED_THREADS_H
00022
00040 typedef struct _MicrofeedThread MicrofeedThread;
00041
00042 typedef struct _MicrofeedThreadPool MicrofeedThreadPool;
00043
00047 typedef struct _MicrofeedMutex MicrofeedMutex;
00048
00049 typedef void* (*MicrofeedThreadFunction)(void* data);
00050
00051 typedef void (*MicrofeedThreadExitCallback)(MicrofeedThread* thread, void* user_data);
00052
00053 typedef struct {
00054 void* (*thread_new)(MicrofeedThreadFunction function, void* data);
00055 void (*thread_free)(void* thread_implementation);
00056 void* (*thread_get_current)(void);
00057 void (*thread_send_signal)(void* thread_implementation, int signal_number);
00058 void (*thread_join)(void* thread_implementation);
00059 void* (*mutex_new)(void);
00060 void (*mutex_free)(void* mutex_implementation);
00061 void (*mutex_lock)(void* mutex_implementation);
00062 void (*mutex_unlock)(void* mutex_implementation);
00063 } MicrofeedThreadFunctions;
00064
00065 void microfeed_thread_set_functions(MicrofeedThreadFunctions* thread_functions);
00066
00067 void microfeed_thread_init(void);
00068 void microfeed_thread_cleanup(void);
00069
00070 MicrofeedThread* microfeed_thread_new(MicrofeedThreadFunction function, void* data);
00071 MicrofeedThread* microfeed_thread_new_with_exit_callback(MicrofeedThreadFunction function, void* data, MicrofeedThreadExitCallback exit_callback, void* user_data);
00072 void microfeed_thread_free(MicrofeedThread* thread);
00073 MicrofeedThread* microfeed_thread_ref(MicrofeedThread* thread);
00074 void microfeed_thread_unref(MicrofeedThread* thread);
00075
00076 MicrofeedThread* microfeed_thread_get_current(void);
00077 void microfeed_thread_send_signal(MicrofeedThread* thread, int signal_number);
00078 void microfeed_thread_join(MicrofeedThread* thread);
00079 unsigned long microfeed_thread_get_id(MicrofeedThread* thread);
00080
00081 MicrofeedThreadPool* microfeed_thread_pool_new(unsigned int maximum_thread_count);
00082 MicrofeedThreadPool* microfeed_thread_pool_new_with_exit_callback(unsigned int max_threads, MicrofeedThreadExitCallback exit_callback, void* user_data);
00083 MicrofeedThread* microfeed_thread_pool_queue_thread(MicrofeedThreadPool* thread_pool, MicrofeedThreadFunction function, void* data);
00084 MicrofeedThread* microfeed_thread_pool_queue_thread_with_exit_callback(MicrofeedThreadPool* thread_pool, MicrofeedThreadFunction function, void* data, MicrofeedThreadExitCallback exit_callback, void* user_data);
00085 unsigned int microfeed_thread_pool_get_started_thread_count(MicrofeedThreadPool* thread_pool);
00086 unsigned int microfeed_thread_pool_get_waiting_thread_count(MicrofeedThreadPool* thread_pool);
00087 void microfeed_thread_pool_set_maximum_thread_count(MicrofeedThreadPool* thread_pool, unsigned int maximum_thread_count);
00088
00089 MicrofeedMutex* microfeed_mutex_new(void);
00090 void microfeed_mutex_free(MicrofeedMutex* mutex);
00091 void microfeed_mutex_lock(MicrofeedMutex* mutex);
00092 void microfeed_mutex_unlock(MicrofeedMutex* mutex);
00093
00099 #endif