[mythtv] QThread vs. pthreads

Daniel Kristjansson danielk at cuymedia.net
Tue Jan 2 13:25:00 UTC 2007


On Thu, 2006-12-28 at 16:30 -0700, Keith Layne wrote:
> The coding standards say to be as platform-independent as possible, but I
> see the pthread lib being used predominantly.  I know a lot of people like
> pthreads, but it isn't very c++, and not that platform-independent.  Is this
> because you only really want to support POSIX-compliant OSes?  I don't
> really have a problem with that, but I also see use of both QThread classes
> and pthreads (like in mythbackend/mainserver.cpp).  Do pthreads have big
> advantages, or is this just a sort of anachronism?  I can't really find any
> discussion on this topic, so I was wondering what the consensus is on
> threads in MythTV.

I think by platform-independent we generally mean it should
either be in POSIX or implemented in Qt 3.1. A lot of UNIX
procedures can be used in a POSIX compliant way, or in a 
non-POSIX compliant way. Newer Qt's support concepts such
as 64 bit integers, but if you use this then you lose
compatibility with some still popular distros.

We also do use some pthread attributes and priority settings
that aren't supported by QThread. Some of the threads could
be implemented as QThreads, but we might as well use the
same thread API for all the threads we can. Plus pthreads
are available on all operating systems MythTV could possibly
run on. For MS Windows it's a tiny library which just
encapsulates the same functionality in WIN32.

-- Daniel



More information about the mythtv-dev mailing list