blob: 60612080acb344f92888f40d03b648af6b6df5d9 [file] [log] [blame]
xjde81d1d2021-11-25 15:01:52 +08001#include <stdio.h>
2#include <pthread.h>
3#include <stdint.h>
4#include <semaphore.h>
5#include <sys/time.h>
6#include <unistd.h>
7#include <stdlib.h>
8#include <string.h>
9#include "thpool.h"
10#include "timeManager/timeManagement.h"
11#if 0
12int main_test(int argc,char **argv)
13{
14 timerArgv *timeMan=(timerArgv*)malloc(sizeof(timerArgv));
15 initTimeManagement(10,timeMan);
16 cond_used_state *node=NULL;
17 for (int i=0;i<5;i++)
18 {
19 request_cond *requestCond=(request_cond*)malloc(sizeof(request_cond));
20 printf("[Warren test] add task %d\n",i);
21 node = findUnusedCond(timeMan->cond_array,CONDARRAYMAX);
22 requestCond->cond_index=node->index;
23 requestCond->requestID=i;
24 printf("[Warren test] cond_index=%d,requestID=%d task %d\n",requestCond->cond_index,requestCond->requestID,i);
25 thpool_add_work(timeMan->pool,startWaitResp,(void*)requestCond);
26 //millli_sleep_with_restart(1);
27 node->use_state = 1;
28 }
29 printf("[Warren test] wait 5s....\n");
30 sleep(5);
31 printf("正在发送信号....\n");
32 pthread_mutex_lock(&timeMan->cond_array[0].mutex);
33 pthread_cond_signal(&timeMan->cond_array[0].cond);
34 pthread_mutex_unlock(&timeMan->cond_array[0].mutex);
35 printf("end cond_0....\n");
36 sleep(3);
37 printf("正在发送信号_2....\n");
38 pthread_mutex_lock(&timeMan->cond_array[2].mutex);
39 pthread_cond_signal(&timeMan->cond_array[2].cond);
40 pthread_mutex_unlock(&timeMan->cond_array[2].mutex);
41 printf("end cond_2\n");
42 printf("正在发送信号_1....\n");
43 sleep(3);
44 pthread_mutex_lock(&timeMan->cond_array[1].mutex);
45 pthread_cond_signal(&timeMan->cond_array[1].cond);
46 pthread_mutex_unlock(&timeMan->cond_array[1].mutex);
47 printf("end cond_1\n");
48 thpool_wait(timeMan->pool);
49 puts("Killing threadpool");
50 thpool_destroy(timeMan->pool);
51 free(timeMan);
52 return 0;
53}
54#endif