"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/components.cc" between
gnuchess-6.2.4.tar.gz and gnuchess-6.2.5.tar.gz

About: GNU Chess is a chess-playing program.

components.cc  (gnuchess-6.2.4):components.cc  (gnuchess-6.2.5)
/* GNU Chess 6 - components.cc - Pipes shared across modules /* GNU Chess 6 - components.cc - Pipes shared across modules
Copyright (c) 2001-2015 Free Software Foundation, Inc. Copyright (c) 2001-2017 Free Software Foundation, Inc.
GNU Chess is based on the two research programs GNU Chess is based on the two research programs
Cobalt by Chua Kong-Sian and Gazebo by Stuart Cracraft. Cobalt by Chua Kong-Sian and Gazebo by Stuart Cracraft.
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
skipping to change at line 31 skipping to change at line 31
Contact Info: Contact Info:
bug-gnu-chess@gnu.org bug-gnu-chess@gnu.org
cracraft@ai.mit.edu, cracraft@stanfordalumni.org, cracraft@earthlink.net cracraft@ai.mit.edu, cracraft@stanfordalumni.org, cracraft@earthlink.net
*/ */
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
#include <unistd.h> #include <unistd.h>
#include <pthread.h> #include <pthread.h>
#include <signal.h>
#include "frontend/common.h" #include "frontend/common.h"
#include "components.h" #include "components.h"
extern unsigned int flags; extern unsigned int flags;
/* Main loop of adapter */ /* Main loop of adapter */
namespace adapter { namespace adapter {
extern pthread_mutex_t adapter_init_mutex; extern pthread_mutex_t adapter_init_mutex;
extern pthread_cond_t adapter_init_cond; extern pthread_cond_t adapter_init_cond;
int main_adapter(int argc,char *argv[]); int main_adapter(int argc,char *argv[]);
} }
/* Main loop of engine */ /* Main loop of engine */
namespace engine { namespace engine {
int main_engine(int argc,char *argv[]); int main_engine(int argc,char *argv[]);
} }
/* Input thread */
pthread_t input_thread;
/* Adapter thread */ /* Adapter thread */
pthread_t adapter_thread; pthread_t adapter_thread;
/* Engine thread */ /* Engine thread */
pthread_t engine_thread; pthread_t engine_thread;
int pipefd_i2f[2];
/* Pipes to communicate frontend and adapter */ /* Pipes to communicate frontend and adapter */
int pipefd_f2a[2]; int pipefd_f2a[2];
int pipefd_a2f[2]; int pipefd_a2f[2];
/* Pipes to communicate adapter and engine */ /* Pipes to communicate adapter and engine */
int pipefd_a2e[2]; int pipefd_a2e[2];
int pipefd_e2a[2]; int pipefd_e2a[2];
/* /*
* Entry point for the input thread
*/
/*void *input_func(void *arg)
{
return 0;
}*/
/*
* Starts the input on a separate thread.
*/
void InitInputThread()
{
/* Create pipes to communicate input and frontend. */
if ( pipe( pipefd_i2f ) != 0 ) {
printf( "Error while creating pipe.\n" );
exit( 1 );
}
/* Start input thread */
pthread_create(&input_thread, NULL, input_func, NULL);
}
/*
* Entry point for the adapter thread * Entry point for the adapter thread
*/ */
void *adapter_func(void *arg) void *adapter_func(void *arg)
{ {
/* Start engine */ /* Start engine */
InitEngine(); InitEngine();
/* Start adapter main loop */ /* Start adapter main loop */
adapter::main_adapter( 0, 0 ); adapter::main_adapter( 0, 0 );
return 0; return 0;
} }
skipping to change at line 141 skipping to change at line 171
if ( ! (flags & UCI ) ) { if ( ! (flags & UCI ) ) {
char data[9]; char data[9];
strcpy( data, "quit" ); strcpy( data, "quit" );
SendToEngine( data ); SendToEngine( data );
} }
pthread_join( engine_thread, NULL ); pthread_join( engine_thread, NULL );
if ( ! (flags & UCI ) ) { if ( ! (flags & UCI ) ) {
pthread_join( adapter_thread, NULL ); pthread_join( adapter_thread, NULL );
} }
} }
void TerminateInput()
{
pthread_cancel( input_thread );
pthread_join( input_thread, NULL );
}
 End of changes. 6 change blocks. 
1 lines changed or deleted 31 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)