TinyThread++

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

asanjuan
Posts: 214
Joined: Thu Sep 01, 2011 5:38 pm
Location: Seville, Spain

Re: TinyThread++

Post by asanjuan »

It seems to me that the whole discussion has gone off-topic. No one here is going to write their own OS, I supose.

Now it is clear to me that people that uses C++11 has gone for the std::thread, and for the rest, the majority is using pthreads and winapi directly, or wrapped somehow.

Discussing about who's programmed a thread at the lowest level is a nonsense today, at least it wasn't my intention when I created the thread. I wanted to know opinions about the library (TinyThread++) from a practical point of view taking into account that is intended to be used inside a chess engine.

Regards.
Still learning how to play chess...
knigths move in "L" shape ¿right?
syzygy
Posts: 5566
Joined: Tue Feb 28, 2012 11:56 pm

Re: TinyThread++

Post by syzygy »

mar wrote:However you seem to be misinterpreting what I call DIY.
If you use pthreads, you're depending on third party libraries.

The point is that what you wrote is not what you really do:
mar wrote:Well I'll give you a simple question, do you prefer to depend on 16kb or 90mb of third-party code? I would personally choose neither and would write my own of course.
And this is also not what you do:
mar wrote:do it yourself (=wrap OS functionality, that's what C++11 libs/boost do anyway, except maybe for some clever hacks).
You're not wrapping OS functionality. You are wrapping pthreads. (C++11 libs most likely are not wrapping pthreads but using syscalls, but I have not checked this... there's no reason to look under the hood.)

OK, one could argue pthreads is part of the OS. But then gcc, g++, stdlibc++ are part of the OS just as much.

There's nothing wrong with wrapping pthreads, obviously. I see nothing wrong with using C++11 threads either, where available.
Rein Halbersma wrote:Full control is an illusion at worst, and a very expensive dream at best. You might as well grow your own vegetables, knit your own clothes and build your own house to rule out any chance of insecticides, child labor and asbestos roofs etc :)
mar
Posts: 2559
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: TinyThread++

Post by mar »

syzygy wrote:If you use pthreads, you're depending on third party libraries.
I think considering POSIX implementation third party libraries is rather extreme, but this is word play anyway.
You're not wrapping OS functionality. You are wrapping pthreads. (C++11 libs most likely are not wrapping pthreads but using syscalls, but I have not checked this... there's no reason to look under the hood.)
See for yourself: https://github.com/mirrors/gcc/blob/mas ... hr-posix.h
syzygy
Posts: 5566
Joined: Tue Feb 28, 2012 11:56 pm

Re: TinyThread++

Post by syzygy »

mar wrote:
syzygy wrote:If you use pthreads, you're depending on third party libraries.
I think considering POSIX implementation third party libraries is rather extreme, but this is word play anyway.
But considering libstdc++ to be a third party library is not extreme?

Imho, the position you were advocating is extreme.
mar
Posts: 2559
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: TinyThread++

Post by mar »

syzygy wrote:But considering libstdc++ to be a third party library is not extreme?

Imho, the position you were advocating is extreme.
But I'm not considering lidstdc++ third party...
syzygy
Posts: 5566
Joined: Tue Feb 28, 2012 11:56 pm

Re: TinyThread++

Post by syzygy »

mar wrote:
syzygy wrote:But considering libstdc++ to be a third party library is not extreme?

Imho, the position you were advocating is extreme.
But I'm not considering lidstdc++ third party...
Well, it seemed you were clearly distinguishing between on the one hand C++11 and on the other hand "do it yourself = wrap OS functionality" (which apparently does not exclude using off-the-shelf pthreads).

So I guess we can now say that using C++11 threads is an example of directly using OS functionality.