Esempio n. 1
0
void factory_init(pfact pf,int th_num,int capacity,pfunc child_fun)
{
	pf->thread = (pthread_t *)calloc(th_num,sizeof(pthread_t));
	pf->th_num = th_num;
	pthread_cond_init(&(pf->cond),NULL);
	pf->capacity = capacity;
	que_init(&(pf->que));
	pf->child_fun = child_fun;
	pf->flag = 0; 
}
Esempio n. 2
0
void factory_init(pfactory_t parr,pfunc pfunc_con,pfunc pfunc_pro,int con_num,int pro_num,int capacity)
{
	que_init(&parr->s_que,capacity);
	parr->pfunc_con=pfunc_con;
	parr->pfunc_pro=NULL;
	pthread_cond_init(&parr->cond,NULL);
	parr->pth_con=(pthread_t *)calloc(con_num,sizeof(pthread_t));
	parr->pth_pro=NULL;
	parr->flag=0;
}
Esempio n. 3
0
void factory_init(pfactory pf,pfunc pth_pfunc,int pth_num,int cap,char *pwd)
{
	pf->pth = (pthread_t*)malloc(pth_num*sizeof(pthread_t));
	pf->p = pth_pfunc;
	pf->pnum = pth_num;
	pf->capability = cap;
	pthread_cond_init(&pf->cond,NULL);
	pf->flag = 0;
	que_init(&pf->fque);
	strcpy(pf->pth_pwd,pwd);
//	printf("%s\n",pf->pth_pwd);
}
Esempio n. 4
0
/*线程池初始化<条件变量/线程池大小(堆空间申请内存)>*/
int pool_init(pool* p/*out*/,int num/*in*/,int cap/*in*/,pfunc entry/*in*/){
		if(pthread_cond_init(&p->cond,NULL)!=0)
		{
				printf("pthread_cond_init() failed\n");
				return -1;
		}

		/*池容量*/
		p->pth=(pthread_t*)calloc(num,sizeof(pthread_t));
		p->entry=entry;

		/*初始化线程池的时候队列也随之初始化*/
		que_init(&p->q,cap);
		p->start=0;
		p->num=num;
		return 0;
}