Author: Miguel A. Ballicora
Date: 08:19:08 12/14/01
Go up one level in this thread
On December 14, 2001 at 08:07:22, Tim Foden wrote: >On December 12, 2001 at 15:46:59, Wylie Garvin wrote: > >>On December 12, 2001 at 10:54:47, Severi Salminen wrote: >> >>>Hi! >>> >>>How do you poll stdin during search? I just want to see if "quit" is sent to >>>engine during search. Otherwise my engine keeps searching even if WB has >>>exited... >>> >>>And I don't know anything about multithreading. And I don't even wat to know ;) >>> >>>Severi >> >>I recommend you take a look at this page on Tim Mann's xboard/winboard site: >>http://www.tim-mann.org/xboard/engine-intf.html#6 >> >>It describes what I consider to be a flexible method for handling input while >>the program is (possibly) thinking. It can be implemented either with a >>periodic polling for input or with multithreaded input. >> >>I successfully applied the methods described on that page a few months ago in a >>Win32 C++ program. The only really bizarre thing I had to deal with was that as >>long as I had an outstanding ReadFile() call blocked in my input thread, all my >>efforts to kill the thread were futile! There are several of this sort of >>bogosity on Win32 platforms. > >:) > >>This one was incredibly annoying because my input >>was actually being *parsed* in the main thread, not the input thread (which I >>think is what makes sense; the engine thinks for a while, then it comes along >>and says, "oho, some input" and then it parses it and does whatever it's >>supposed to do). I eventually added a BRUTAL hack to the input thread so that >>on detecting a case variant of the string "quit\n" it would cleanly terminate >>itself. Yuck. > >You could probably fix it by having the main thread close the file handle. This >should cause the ReadFile to return with an error status, which you could >detect, and then exit cleanly from the thread. I do this different. The main thread is the "input" or "interface" thread and the "engine" thread is called by the interface thread. In this way, the interface thread is always in control. It launches the engine to think, ponder, analyze etc. It also kills it through a STOP_FLAG global variable. I do not think it is a good idea to have the engine to control the interface. It sounds counter-intuitive to me. Regards, Miguel > >>good luck, >>wylie > >Cheers, Tim.
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.