diep wrote:You cannot do blocking read of course in the thread that commands the search. A 3d thread is used for that in Diep in its own DEP protocol.Sven Schüle wrote:Actually I wondered about exactly the same thing. A blocking read does not eat CPU time. Sleep() is not appropriate here IMO.mar wrote:Hi Vincent,diep wrote: b) here is most important problem: that is that the i/o thread you don't want it to eat a full core. So basically you need to call Sleep there.
I have it sleep 10 milliseconds for example each time. Now that seems fine, except when you want to play super superbullet type games with your engine.
I wonder why you sleep in the I/O thread? I have a plain while ( fgets() ) loop and haven't noticed the I/O thread eat any CPU time. Perhaps you read the input in a different way?
I thought that fgets on stdin should always be blocking...
Martin
Sven
I don't get the meaning of your reply, nor the "of course" in it. In your other reply to Bob you state almost exactly the opposite. So where is the problem you see in my statement? Obviously others, like Bob, have already done exactly what I mentioned (one thread doing a blocking read and one or more threads for searching), and it worked. It requires each searching thread to poll for timeout or external cancellation (the latter issued by the "I/O thread") but both polling for input and actually processing the input is done exclusively by the "I/O thread".
Sven