We want to keep three loosely-coupled modules in GNU Chess v6:
The main program contains the frontend and starts two addtional threads, one for the adapter, and another one for the engine. The three components comprise a chain, thus there are two links:
The links are based on pipes. There is no need for additional synchronization mechanisms such as mutex. The changes in PolyGlot and Fruit are minimal, since they were already using the same mechanism to communicate with each other.
Another technical problem was the fact that GNU Chess v5 was written in C, whereas PolyGlot and Fruit are written in C++. In GNU Chess v6 the main program, the adapter and the engine are in C++, but the frontend remains in C.
Source code was placed under a single src in GNU Chess v5, as usual. Three additional directories have been created for GNU Chess v6, so the code is organized in four directories:
main and a source file used to create the pipes that
communicate the three modules: frontend, adapter and engine.
Contains the frontend. The code here is inherited from GNU Chess v5, with some modifications mainly in cmd.c and a new file engine.c which addresses the message passing through modules.
Contains the chess protocol adapter, based on PolyGlot 1.4. Minor changes, wrt the baseline.
Contains the chess engine, based on Fruit 2.1. Minor changes wrt the baseline.
The sources in each src subdirectory are compiled as a static library.
When link with the sources in top src, they result into the binary
gnuchess. The module libraries are named after their respective
libfrontend.a libadapter.a libengine.a