gochatai/pachi_py/pachi/distributed/protocol.c
/* Allocate the receive queue, and create the slave and proxy threads.
 * max_buf_size and the merge-related fields of default_sstate must
 * already be initialized. */
Allocate the receive queue, and create the slave and proxy threads.
max_buf_size and the merge-related fields of default_sstate must
already be initialized.
Allocate the receive queue and create the slave and proxy threads . max_buf_size and the merge - related fields of default_sstate must already be initialized .
void
protocol_init(char *slave_port, char *proxy_port, int max_slaves)
{
	start_time = time_now();
	queue_max_length = max_slaves * MAX_GENMOVES_PER_SLAVE;
	receive_queue = calloc2(queue_max_length, sizeof(*receive_queue));
	default_sstate.slave_sock = port_listen(slave_port, max_slaves);
	default_sstate.last_processed = -1;
	for (int n = 0; n < BUFFERS_PER_SLAVE; n++) {
		default_sstate.b[n].queue_index = -1;
	}
	pthread_t thread;
	for (int id = 0; id < max_slaves; id++) {
		pthread_create(&thread, NULL, slave_thread, (void *)(intptr_t)id);
	}
	if (proxy_port) {
		int proxy_sock = port_listen(proxy_port, max_slaves);
		for (int id = 0; id < max_slaves; id++) {
			pthread_create(&thread, NULL, proxy_thread, (void *)(intptr_t)proxy_sock);
		}
	}
}
void protocol_init ( char * slave_port , char * proxy_port , int max_slaves ) { start_time = time_now ( ) ; queue_max_length = max_slaves * MAX_GENMOVES_PER_SLAVE ; receive_queue = calloc2 ( queue_max_length , sizeof ( * receive_queue ) ) ; default_sstate . slave_sock = port_listen ( slave_port , max_slaves ) ; default_sstate . last_processed = -1 ; for ( int n = 0 ; n < BUFFERS_PER_SLAVE ; n ++ ) { default_sstate . b [ n ] . queue_index = -1 ; } pthread_t thread ; for ( int id = 0 ; id < max_slaves ; id ++ ) { pthread_create ( & thread , NULL , slave_thread , ( void * ) ( intptr_t ) id ) ; } if ( proxy_port ) { int proxy_sock = port_listen ( proxy_port , max_slaves ) ; for ( int id = 0 ; id < max_slaves ; id ++ ) { pthread_create ( & thread , NULL , proxy_thread , ( void * ) ( intptr_t ) proxy_sock ) ; } } }
Allocate the receive queue, and create the slave and proxy threads.
Allocate the receive queue and create the slave and proxy threads .