#include <stdio.h> | |
#include <pthread.h> | |
#include <stdint.h> | |
#include <semaphore.h> | |
#include <sys/time.h> | |
#include <unistd.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include "thpool.h" | |
#include "timeManager/timeManagement.h" | |
#if 0 | |
int main_test(int argc,char **argv) | |
{ | |
timerArgv *timeMan=(timerArgv*)malloc(sizeof(timerArgv)); | |
initTimeManagement(10,timeMan); | |
cond_used_state *node=NULL; | |
for (int i=0;i<5;i++) | |
{ | |
request_cond *requestCond=(request_cond*)malloc(sizeof(request_cond)); | |
printf("[Warren test] add task %d\n",i); | |
node = findUnusedCond(timeMan->cond_array,CONDARRAYMAX); | |
requestCond->cond_index=node->index; | |
requestCond->requestID=i; | |
printf("[Warren test] cond_index=%d,requestID=%d task %d\n",requestCond->cond_index,requestCond->requestID,i); | |
thpool_add_work(timeMan->pool,startWaitResp,(void*)requestCond); | |
//millli_sleep_with_restart(1); | |
node->use_state = 1; | |
} | |
printf("[Warren test] wait 5s....\n"); | |
sleep(5); | |
printf("正在发送信号....\n"); | |
pthread_mutex_lock(&timeMan->cond_array[0].mutex); | |
pthread_cond_signal(&timeMan->cond_array[0].cond); | |
pthread_mutex_unlock(&timeMan->cond_array[0].mutex); | |
printf("end cond_0....\n"); | |
sleep(3); | |
printf("正在发送信号_2....\n"); | |
pthread_mutex_lock(&timeMan->cond_array[2].mutex); | |
pthread_cond_signal(&timeMan->cond_array[2].cond); | |
pthread_mutex_unlock(&timeMan->cond_array[2].mutex); | |
printf("end cond_2\n"); | |
printf("正在发送信号_1....\n"); | |
sleep(3); | |
pthread_mutex_lock(&timeMan->cond_array[1].mutex); | |
pthread_cond_signal(&timeMan->cond_array[1].cond); | |
pthread_mutex_unlock(&timeMan->cond_array[1].mutex); | |
printf("end cond_1\n"); | |
thpool_wait(timeMan->pool); | |
puts("Killing threadpool"); | |
thpool_destroy(timeMan->pool); | |
free(timeMan); | |
return 0; | |
} | |
#endif |