INLINE int get_eval(){ int ret; #ifndef WIN32 ret = uvalarm(2*max_cost, 0); uvalarm(ret, 0); return ret; #else return 100; #endif }
INLINE void set_eval(int etime){ #ifndef WIN32 signal(SIGVTALRM, sigalrm_handler); uvalarm(max_cost, 0); #endif outoftime = 0; }
void set_eval(int etime){ #ifndef WIN32 long diff; if((diff = time(0)-current_time) > 1){ diff *= 1000000; if(diff > max_cost*100){ //put some hard limit to eval times outoftime = 1; return; } } signal(SIGVTALRM, sigalrm_handler); uvalarm(etime, 0); gettimeofday(&tv, NULL); #endif outoftime = 0; }
void set_eval(int etime){ #ifndef WIN32 long diff; gettimeofday(&tv, NULL); if((diff = tv.tv_sec-current_time) > 1){ diff *= 1000000; if(diff > max_cost*100L){ //put some hard limit to eval times debug(d_flag, ("difft:%ld, max_cost:%d", diff, max_cost)); outoftime = 1; return; } } signal(SIGVTALRM, sigalrm_handler); uvalarm(etime, 0); #endif outoftime = 0; }