~vcs-imports-ii/gnuchess/trunk

« back to all changes in this revision

Viewing changes to src/components.cc

  • Committer: aceballos
  • Date: 2017-06-12 21:52:45 UTC
  • Revision ID: svn-v4:6006247a-2d13-4e52-b961-62b44c6c37c8:trunk:157
Tags: v6.2.5-rc2
merge --reintegrate branches/readline; release 6.2.5-rc2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* GNU Chess 6 - components.cc - Pipes shared across modules
2
2
 
3
 
   Copyright (c) 2001-2015 Free Software Foundation, Inc.
 
3
   Copyright (c) 2001-2017 Free Software Foundation, Inc.
4
4
 
5
5
   GNU Chess is based on the two research programs
6
6
   Cobalt by Chua Kong-Sian and Gazebo by Stuart Cracraft.
28
28
#include <cstring>
29
29
#include <unistd.h>
30
30
#include <pthread.h>
 
31
#include <signal.h>
31
32
 
32
33
#include "frontend/common.h"
33
34
#include "components.h"
46
47
  int main_engine(int argc,char *argv[]);
47
48
}
48
49
 
 
50
/* Input thread */
 
51
pthread_t input_thread;
 
52
 
49
53
/* Adapter thread */
50
54
pthread_t adapter_thread;
51
55
 
52
56
/* Engine thread */
53
57
pthread_t engine_thread;
54
58
 
 
59
int pipefd_i2f[2];
 
60
 
55
61
/* Pipes to communicate frontend and adapter */
56
62
int pipefd_f2a[2];
57
63
int pipefd_a2f[2];
61
67
int pipefd_e2a[2];
62
68
 
63
69
/*
 
70
 * Entry point for the input thread
 
71
 */
 
72
/*void *input_func(void *arg)
 
73
{
 
74
  return 0;
 
75
}*/
 
76
 
 
77
/*
 
78
 * Starts the input on a separate thread.
 
79
 */
 
80
 
 
81
void InitInputThread()
 
82
{
 
83
  /* Create pipes to communicate input and frontend. */
 
84
  if ( pipe( pipefd_i2f ) != 0 ) {
 
85
    printf( "Error while creating pipe.\n" );
 
86
    exit( 1 );
 
87
  }
 
88
 
 
89
  /* Start input thread */
 
90
  pthread_create(&input_thread, NULL, input_func, NULL);
 
91
}
 
92
 
 
93
/*
64
94
 * Entry point for the adapter thread
65
95
 */
66
96
void *adapter_func(void *arg)
139
169
  }
140
170
}
141
171
 
 
172
void TerminateInput()
 
173
{
 
174
  pthread_cancel( input_thread );
 
175
  pthread_join( input_thread, NULL );
 
176
}