lux/dist/common.h

00001 #ifndef LUX_DIST_COMMON_H
00002 #define LUX_DIST_COMMON_H
00003 
00004 #include "lux/lux.h"
00005 #include "util.h"
00006 #include <pthread.h>
00007 #include <string>
00008 #include <vector>
00009 
00010 // temporary. should be moved
00011 typedef int sock_t;
00012 typedef uint32_t server_id_t;
00013 
00014 typedef std::vector<std::string> str_vec;
00015 typedef str_vec::iterator str_vec_itr;
00016 
00017 namespace Lux {
00018 namespace Dist {
00019 
00020   // it's shared in all threads,
00021   // so it must be locked before update
00022   typedef struct {
00023     uint16_t num_threads;
00024     uint16_t num_active_threads;
00025     uint32_t num_processed;
00026     pthread_mutex_t *mutex;
00027     pthread_cond_t *cond;
00028   } global_thread_stats_t;
00029 
00030   typedef struct {
00031     pthread_t tid; // thread id
00032     sock_t sock;
00033     global_thread_stats_t *stats;
00034     void *supp_arg; // supplementary thread argument
00035   } thread_inf_t;
00036 
00037   typedef struct {
00038     in_addr_t ip;
00039     sock_t socket;
00040     uint16_t port;
00041     uint32_t id;
00042   } server_inf_t;
00043 
00044   typedef struct {
00045     uint16_t num_threads;
00046     pthread_mutex_t *mutex;
00047   } global_client_thread_inf_t;
00048 
00049   typedef struct {
00050     pthread_t tid; // thread id
00051     server_inf_t *server;
00052     void *queue;
00053     bool is_terminating;
00054   } client_thread_inf_t;
00055 
00056 }
00057 }
00058 
00059 #endif

Generated on Fri Feb 5 15:50:30 2010 for Lux by  doxygen 1.4.7