Author: Frank Phillips
Date: 10:19:22 04/09/02
Go up one level in this thread
First of all thanks to everyone who responded.
On the thread stuff, I have tried an approach similar the code below, but never
it got it work properly with therest of my approach to input.
(Scott) are you saying you do not bother with the cond_wait statement and just
increment a buffer counter for items of input to be parsed, so effectively the
thread is always stuffing available input into the buffer? I guess you lock the
buffer during reads? It would mean a redesign of the input and parsing
routines, but is attractively clean and, as you say, lets you deal with some
input without bothering the search.
Frank
void *ReadFunction(void *arg)
{
for (;;)
{
pthread_mutex_lock(&mutex_fData);
if (fData == 0)
{
cin >> input_buffer;
//cout << "text in = " << input_buffer << endl;
//getchar();
fData=1;
pthread_cond_wait(&cond_fData,&mutex_fData);
}
pthread_mutex_unlock(&mutex_fData);
}
return NULL;
}
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.