00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __ModuleData_h__
00023 #define __ModuleData_h__
00024
00025 #include <OPENR/OPENR.h>
00026 #include <opensdkAPI.h>
00027 #include <pthread.h>
00028 #include <semaphore.h>
00029 #include <map>
00030 #include <queue>
00031 #include <utility>
00032 #include <list>
00033
00034 struct DesignData {
00035 void *base;
00036 size_t size;
00037 };
00038
00039 struct message {
00040 OServiceEntry entry;
00041 void *msg;
00042 message(OServiceEntry entry_, void *msg_) : entry(entry_), msg(msg_) {}
00043 };
00044
00045 struct perThreadStruct {
00046
00047 std::map<ODesignDataID, DesignData> designDataIDs;
00048 ODesignDataID lastDesignDataID;
00049
00050
00051 sem_t sem;
00052
00053
00054 pthread_cond_t cond;
00055 pthread_mutex_t cond_mutex;
00056 bool exited;
00057
00058 bool DoInitCompleted;
00059 bool DoStopCompleted;
00060
00061 size_t OID;
00062 pthread_t threadId;
00063
00064 std::queue<message> queue;
00065 pthread_mutex_t queue_mutex;
00066
00067 std::list< std::pair<int,int> > ConnectHandlers;
00068
00069 char *strtok_ptr;
00070
00071
00072 perThreadStruct(size_t OID_)
00073 {
00074 lastDesignDataID = 0;
00075 OID = OID_;
00076 exited = false;
00077 DoInitCompleted = false;
00078 DoStopCompleted = false;
00079
00080 sem_init(&sem, 0, 0);
00081 pthread_cond_init(&cond, NULL);
00082 pthread_mutex_init(&cond_mutex, NULL);
00083 pthread_mutex_init(&queue_mutex, NULL);
00084 }
00085
00086
00087 ~perThreadStruct()
00088 {
00089 sem_destroy(&sem);
00090 pthread_cond_destroy(&cond);
00091 pthread_mutex_destroy(&cond_mutex);
00092 pthread_mutex_destroy(&queue_mutex);
00093 }
00094 };
00095
00096 #define MOD_DATA(x) (((perThreadStruct*)pthread_getspecific(perThreadKey))->x)
00097
00098 #endif