add front demo in this project
This commit is contained in:
@@ -4,10 +4,14 @@
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
|
||||
|
||||
#include "PQSMsg.h"
|
||||
#include "client2.h"
|
||||
#include "dealMsg.h"
|
||||
|
||||
#include "cloudfront/code/interface.h"
|
||||
#if 0
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
#define THREAD_CONNECTIONS 10 // <20><><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD><DFB3><EFBFBD>
|
||||
#define MONITOR_INTERVAL 1 // <20><><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD>(<28><>)
|
||||
@@ -27,7 +31,7 @@ typedef struct {
|
||||
thread_state_t state; // <20><>ǰ״̬
|
||||
pthread_mutex_t lock; // <20>߳<EFBFBD>ר<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
||||
} thread_info_t;
|
||||
|
||||
#endif
|
||||
/* ȫ<>ֱ<EFBFBD><D6B1><EFBFBD> */
|
||||
thread_info_t thread_info[THREAD_CONNECTIONS]; // <20>߳<EFBFBD><DFB3><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
|
||||
pthread_mutex_t global_lock = PTHREAD_MUTEX_INITIALIZER; // ȫ<>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD><EFBFBD>
|
||||
@@ -161,6 +165,19 @@ void restart_thread(int index) {
|
||||
free(new_index);
|
||||
}
|
||||
}
|
||||
else if (index == 2) {
|
||||
// <20>ӿڣ<D3BF>mq
|
||||
char* argv[] = { (char*)new_index ,(char*)"-dcfg_stat_data", (char*)"-s1_1" };
|
||||
ThreadArgs* args = new ThreadArgs{3, argv};
|
||||
if (pthread_create(&thread_info[index].tid, NULL, cloudfrontthread, args) != 0) {
|
||||
pthread_mutex_lock(&global_lock);
|
||||
printf("Failed to restart message processor thread %d\n", index);
|
||||
thread_info[index].state = THREAD_CRASHED;
|
||||
pthread_mutex_unlock(&global_lock);
|
||||
delete args; // <20><><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD>ֶ<EFBFBD><D6B6>ͷ<EFBFBD>
|
||||
free(new_index);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>ʵ<EFBFBD><CAB5>Ӧ<EFBFBD><D3A6><EFBFBD>п<EFBFBD><D0BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
|
||||
@@ -169,7 +186,8 @@ void restart_thread(int index) {
|
||||
|
||||
/* <20>̴߳<DFB3><CCB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
int is_thread_alive(pthread_t tid) {
|
||||
return pthread_tryjoin_np(tid, NULL) == EBUSY; // EBUSY<53><59>ʾ<EFBFBD>߳<EFBFBD><DFB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//return pthread_tryjoin_np(tid, NULL) == EBUSY; // EBUSY<53><59>ʾ<EFBFBD>߳<EFBFBD><DFB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
return pthread_kill(tid, 0) == 0; //<2F><><EFBFBD><EFBFBD>
|
||||
}
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
@@ -202,6 +220,16 @@ int main() {
|
||||
free(index);
|
||||
}
|
||||
}
|
||||
else if (i == 2){
|
||||
//<2F>ӿں<D3BF>mq
|
||||
char* argv[] = { (char*)index,(char*)"-dcfg_stat_data", (char*)"-s1_1" };
|
||||
ThreadArgs* args = new ThreadArgs{3, argv};
|
||||
if (pthread_create(&thread_info[i].tid, NULL, cloudfrontthread, args) != 0) {
|
||||
printf("Failed to create message processor thread %d\n", i);
|
||||
delete args; // <20><><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD>ֶ<EFBFBD><D6B6>ͷ<EFBFBD>
|
||||
free(index);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>ʵ<EFBFBD><CAB5>Ӧ<EFBFBD><D3A6><EFBFBD>п<EFBFBD><D0BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
|
||||
|
||||
Reference in New Issue
Block a user