00001 /* SVN FILE INFO 00002 * $Revision: 423 $ : Last Committed Revision 00003 * $Date: 2009-09-11 16:14:33 -0700 (Fri, 11 Sep 2009) $ : Last Committed Date */ 00004 /*[ 00005 * Copyright (c) 2007 Integration Engineering Laboratory 00006 University of California, Davis 00007 * 00008 * Permission to use, copy, and distribute this software and its 00009 * documentation for any purpose with or without fee is hereby granted, 00010 * provided that the above copyright notice appear in all copies and 00011 * that both that copyright notice and this permission notice appear 00012 * in supporting documentation. 00013 * 00014 * Permission to modify the software is granted, but not the right to 00015 * distribute the complete modified source code. Modifications are to 00016 * be distributed as patches to the released version. Permission to 00017 * distribute binaries produced by compiling modified sources is granted, 00018 * provided you 00019 * 1. distribute the corresponding source modifications from the 00020 * released version in the form of a patch file along with the binaries, 00021 * 2. add special version identification to distinguish your version 00022 * in addition to the base release version number, 00023 * 3. provide your name and address as the primary contact for the 00024 * support of your modified version, and 00025 * 4. retain our contact information in regard to use of the base 00026 * software. 00027 * Permission to distribute the released version of the source code along 00028 * with corresponding source modifications in the form of a patch file is 00029 * granted with same provisions 2 through 4 for binary distributions. 00030 * 00031 * This software is provided "as is" without express or implied warranty 00032 * to the extent permitted by applicable law. 00033 ]*/ 00034 00035 #ifndef _ACC_H_ 00036 #define _ACC_H_ 00037 #ifndef _WIN32 00038 #include <sys/socket.h> 00039 #else 00040 #include <windows.h> 00041 #include <winsock.h> 00042 #endif 00043 #include "macros.h" 00044 00045 struct mc_platform_s; 00046 00047 struct connection_thread_arg_s; 00048 STRUCT( 00049 acc, 00050 struct mc_platform_s* mc_platform; 00051 THREAD_T thread; 00052 THREAD_T message_handler_thread; 00053 THREAD_T listen_thread; 00054 THREAD_T udplisten_thread; 00055 00056 /* waiting flag: Note that this flag only applies to the listen_thread */ 00057 int waiting; 00058 MUTEX_T* waiting_lock; 00059 COND_T* waiting_cond; 00060 00061 /* Connection Queue Threads */ 00062 int num_conn_threads; 00063 THREAD_T conn_thread; 00064 MUTEX_T conn_thread_lock; 00065 COND_T conn_thread_cond; 00066 struct connection_thread_arg_s* connection_thread_arg; 00067 00068 /* Msg Queue Threads */ 00069 int num_msg_threads; 00070 THREAD_T msg_thread; 00071 MUTEX_T msg_thread_lock; 00072 COND_T msg_thread_cond; 00073 ) 00074 00075 STRUCT( 00076 listen_thread_arg, 00077 u_long port; 00078 struct sockaddr_in *addr; 00079 unsigned long int client_fd; 00080 unsigned long int server_fd; 00081 ); 00082 00083 struct connection_s; 00084 STRUCT( 00085 connection_thread_arg, 00086 struct mc_platform_s* mc_platform; 00087 struct connection_s* connection; 00088 ) 00089 00090 00091 acc_p 00092 acc_Initialize(struct mc_platform_s* mc_platform); 00093 00094 int 00095 acc_Destroy(acc_p acc); 00096 00097 void 00098 acc_Start(struct mc_platform_s* mc_platform); 00099 00100 #ifndef _WIN32 00101 void* 00102 acc_MessageHandlerThread(void* arg); 00103 00104 void* 00105 acc_Thread(void* arg); 00106 00107 void* 00108 acc_connection_Thread(void* arg); 00109 00110 void* 00111 listen_Thread(void* arg); 00112 00113 void* 00114 udplisten_Thread(void* arg); 00115 #else 00116 DWORD WINAPI 00117 acc_MessageHandlerThread( LPVOID arg ); 00118 00119 DWORD WINAPI 00120 acc_Thread( LPVOID arg ); 00121 00122 DWORD WINAPI 00123 acc_connection_Thread( LPVOID arg ); 00124 00125 DWORD WINAPI 00126 listen_Thread( LPVOID arg ); 00127 00128 DWORD WINAPI 00129 udplisten_Thread( LPVOID arg ); 00130 #endif /* _WIN32 */ 00131 00132 #endif