00001 /* Gearman server and library 00002 * Copyright (C) 2008 Brian Aker, Eric Day 00003 * All rights reserved. 00004 * 00005 * Use and distribution licensed under the BSD license. See 00006 * the COPYING file in the parent directory for full text. 00007 */ 00008 00014 #ifndef __GEARMAN_SERVER_THREAD_H__ 00015 #define __GEARMAN_SERVER_THREAD_H__ 00016 00017 #ifdef __cplusplus 00018 extern "C" { 00019 #endif 00020 00030 struct gearman_server_thread_st 00031 { 00032 struct { 00033 bool allocated; 00034 } options; 00035 uint32_t con_count; 00036 uint32_t io_count; 00037 uint32_t proc_count; 00038 uint32_t free_con_count; 00039 uint32_t free_packet_count; 00040 gearman_universal_st *gearman; 00041 gearman_server_st *server; 00042 gearman_server_thread_st *next; 00043 gearman_server_thread_st *prev; 00044 gearman_log_fn *log_fn; 00045 void *log_context; 00046 gearman_server_thread_run_fn *run_fn; 00047 void *run_fn_arg; 00048 gearman_server_con_st *con_list; 00049 gearman_server_con_st *io_list; 00050 gearman_server_con_st *proc_list; 00051 gearman_server_con_st *free_con_list; 00052 gearman_server_packet_st *free_packet_list; 00053 gearman_universal_st gearman_universal_static; 00054 pthread_mutex_t lock; 00055 }; 00056 00066 GEARMAN_API 00067 gearman_server_thread_st * 00068 gearman_server_thread_create(gearman_server_st *server, 00069 gearman_server_thread_st *thread); 00070 00076 GEARMAN_API 00077 void gearman_server_thread_free(gearman_server_thread_st *thread); 00078 00085 GEARMAN_API 00086 const char *gearman_server_thread_error(gearman_server_thread_st *thread); 00087 00094 GEARMAN_API 00095 int gearman_server_thread_errno(gearman_server_thread_st *thread); 00096 00104 GEARMAN_API 00105 void gearman_server_thread_set_event_watch(gearman_server_thread_st *thread, 00106 gearman_event_watch_fn *event_watch, 00107 void *event_watch_arg); 00108 00117 GEARMAN_API 00118 void gearman_server_thread_set_log_fn(gearman_server_thread_st *thread, 00119 gearman_log_fn *function, 00120 void *context, 00121 gearman_verbose_t verbose); 00122 00130 GEARMAN_API 00131 void gearman_server_thread_set_run(gearman_server_thread_st *thread, 00132 gearman_server_thread_run_fn *run_fn, 00133 void *run_arg); 00134 00142 GEARMAN_API 00143 gearman_server_con_st * 00144 gearman_server_thread_run(gearman_server_thread_st *thread, 00145 gearman_return_t *ret_ptr); 00146 00149 #ifdef __cplusplus 00150 } 00151 #endif 00152 00153 #endif /* __GEARMAN_SERVER_THREAD_H__ */