Example #1
0
DWORD WINAPI  ThreadFunc(LPVOID lpParam)
{
	if(WaitForSingleObject(Engine_ready_ok,INFINITE)!= WAIT_OBJECT_0){
		my_log("what happened?\n");//i have no idea!
		return 0;
	}
	//seed the random number generator!
	my_random_init();
	//got a "readyok" so we are done done initializing the engine
	my_log("Started xboard_step() thread \n");
	xboard_step();//runs in a loop
	return 0;//
}
Example #2
0
static void adapter_step() {

   fd_set set[1];
   int fd_max;
   int val;

   // process buffered lines

   while (io_line_ready(XBoard->io)) xboard_step(); // process available xboard lines
   while (io_line_ready(Engine->io)) engine_step(); // process available engine lines

   // init

   FD_ZERO(set);
   fd_max = -1; // HACK

   // add xboard input

   ASSERT(XBoard->io->in_fd>=0);

   FD_SET(XBoard->io->in_fd,set);
   if (XBoard->io->in_fd > fd_max) fd_max = XBoard->io->in_fd;

   // add engine input

   ASSERT(Engine->io->in_fd>=0);

   FD_SET(Engine->io->in_fd,set);
   if (Engine->io->in_fd > fd_max) fd_max = Engine->io->in_fd;

   // wait for something to read (no timeout)

   ASSERT(fd_max>=0);

   val = select(fd_max+1,set,NULL,NULL,NULL);
   if (val == -1 && errno != EINTR) my_fatal("adapter_step(): select(): %s\n",strerror(errno));

   if (val > 0) {
      if (FD_ISSET(XBoard->io->in_fd,set)) io_get_update(XBoard->io); // read some xboard input
      if (FD_ISSET(Engine->io->in_fd,set)) io_get_update(Engine->io); // read some engine input
   }
}