For context: I am currently porting Stockfish to WebAssembly, where creating pthreads, even idle ones, is very expensive. This brought my attention to uiThread, which (as far as I can tell) is just a dummy and only ever sleeps.
It was introduced in bdeda52efd55c97d0f5da908267c01f973371e5d and appears to be used only once:
In particular it is not used here (intentionally?):
https://github.com/official-stockfish/Stockfish/blob/651450023619ddea590f301f040286151004df66/src/uci.cpp#L70
If we just need any dummy thread, can't we just use Threads.main() also the first time and get rid of uiThread?
If not, how about not actually instanciating an unsed OS thread? No worries if this is too annoying - I can easily patch this in my WASM port.
My feeling is that you could. Maybe you could try editing the c++ code, see if it still work, and open a PR, you don't need a test on fishtest for that.
Rejected PR for reference: #1995
@mcostalba Can you please explain to what conclusion you came?
Should uiThread be removed (#1995), or is there a data race by using Thread.main() in position(), or is there a third option that I am missing?
Oooops :-)
@snicolet What's the conclusion?
Most helpful comment
Oooops :-)