Computer Chess Club Archives


Search

Terms

Messages

Subject: C++ I/O question (OT)

Author: David Rasmussen

Date: 04:47:12 02/17/01


I am about to add pondering and other things to my program, and I basically need
unblocking I/O. As I can see from everybody elses sourcecode and by asking
experts, there is no way to do this in a portable way in C++. That is in itself
annoying, as it would be no problem to have a stream method that tried to fetch
some items from the underlying buffer or I/O device, and if there wasn't any
items immediately, it returned.

That being said, I would like to do the next best thing. I would like to have
the simplest and "most" portable way of doing this. I'm beginning to think that
the most portable way (and also the simplest way) is to use pthreads from the
start (which would come in handy anyway, if I decided to make a multiprocessor
version of my program), and have a seperate threat listening on cin for new
input. In this way I wouldn't have to deal with the console vs. pipe issue under
certain OS'es, i.e. Windows. I think pthreads exists on most platforms that I
would care about. Or at least some very equivalent thread library, that would
make it easy to have #defines or inline functions "translating" from pthread
calls to these calls.

Anyway, I don't have any clear question other than: What is your take on this?
What would you do? How has this been done? etc.

I'm aware that Crafty implements a way to do this, that others have borrowed.
But to be honest, I don't like Crafty's solution very much. I would like
something simpler, more portable etc. perhaps utilizing something that C++ has
that C does not have.



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.