threads

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
cdani
Posts: 2204
Joined: Sat Jan 18, 2014 10:24 am
Location: Andorra

threads

Post by cdani »

Hello.
To use threads the same way in Windows and in Linux, I will use pevents:
https://github.com/neosmart/pevents
that emulates events the Windows way in Linux.
Someone has used it? It works well?
Many thanks.
elcabesa
Posts: 855
Joined: Sun May 23, 2010 1:32 pm

Re: threads

Post by elcabesa »

Hi dany,
I today don't use any windows/linux specific code using modern c++ threading libraries, they are present since C++11.
if you don't use C and use c++ I thin they are present in C11 too.
User avatar
xr_a_y
Posts: 1871
Joined: Sat Nov 25, 2017 2:28 pm
Location: France

Re: threads

Post by xr_a_y »

For lazy smp, I guess stockfish implementation is the simplest one using c++11.
Easy example of use visible in Minic.
Ras
Posts: 2487
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: threads

Post by Ras »

I'm just using Posix-threads on Linux/Android and Win-API on Windows, with some ifdef wrapper functions.

If anything, I would use Posix under Windows (via MingW) because Windows is the only platform that needs something else. If you emulate Windows behaviour on Linux, then you have to test that thoroughly under Android, Mac and iOS. The potential for issues multiplies up. If you instead emulate Posix on Windows, than that's only one platform where you might run into non-native issues and find workarounds.
Rasmus Althoff
https://www.ct800.net
jdart
Posts: 4366
Joined: Fri Mar 10, 2006 5:23 am
Location: http://www.arasanchess.org

Re: threads

Post by jdart »

elcabesa wrote: Sun Nov 25, 2018 8:47 pm Hi dany,
I today don't use any windows/linux specific code using modern c++ threading libraries, they are present since C++11.
if you don't use C and use c++ I thin they are present in C11 too.
The C++11 stuff is almost portable, but if you need to set the thread stack size, it doesn't do that.

--Jon
User avatar
cdani
Posts: 2204
Joined: Sat Jan 18, 2014 10:24 am
Location: Andorra

Re: threads

Post by cdani »

Many thanks to all! I will review all this.