Opened 11 years ago

Closed 8 years ago

#5501 closed task (Fixed)

Convert pthreads -> Mthread

Reported by: Isaac Richards Owned by: danielk
Priority: minor Milestone: unknown
Component: MythTV - General Version: head
Severity: medium Keywords:
Cc: Ticket locked: no

Description


Attachments (11)

audio_qthread.diff (22.6 KB) - added by Isaac Richards 11 years ago.
mthread-v1.patch (187.9 KB) - added by danielk 8 years ago.
Work in progress..
mthread-v2.patch (212.8 KB) - added by danielk 8 years ago.
Now the plugins also compile + misc fixes.
mthread-v3.patch (219.2 KB) - added by danielk 8 years ago.
mthread-v4.patch (233.7 KB) - added by danielk 8 years ago.
mthread-v5.patch (233.3 KB) - added by danielk 8 years ago.
fix segfault on myth system thread shutdown when they weren't started in the first place.
0002-Change-new-gallery-filter-to-MThread.patch (2.0 KB) - added by beirdo 8 years ago.
Additional patch (goes with mthread-v5) to change new mythgallery filter thread to mthread
mthread-v6.patch (236.0 KB) - added by danielk 8 years ago.
Converts new mythgallery thread to MThread, fixes static DB connection cleanup.
mthread-v7.patch (238.0 KB) - added by danielk 8 years ago.
Reuses DB connection on a per thread basis
mthread-v8.patch (237.9 KB) - added by danielk 8 years ago.
fix purge db conections object's ownership
mthread-v10.patch.bz2 (49.9 KB) - added by danielk 8 years ago.
Converts various threadpools to MThreadPool and fixes the MThreadPool tracking for StopAllPools?()/ShutdownAllPools?()

Download all attachments as: .zip

Change History (46)

Changed 11 years ago by Isaac Richards

Attachment: audio_qthread.diff added

comment:1 Changed 11 years ago by Isaac Richards

Milestone: unknown0.22
Status: newaccepted
Type: defecttask
Version: unknownhead

comment:2 Changed 11 years ago by Isaac Richards

(In [17729]) pthread -> QThread for audio output.

Refs #5501.

comment:3 Changed 11 years ago by paulh

(In [17810]) Switch the Lirc, Joystick and AppleRemote? pthreads to QThreads.

Nigel you may want to check the AppleRemote? stuff I couldn't test any of that.

Refs #5350,#5501

comment:4 Changed 11 years ago by Nigel

(In [18133]) Fix AppleRemote? re-entrancy bug. The CFRunLoop didn't like being started, stopped, and then re-started, so I have gone back to the original code. (which never actually deleted the object -

it just re-used the first-created instance). Refs #5501.

comment:5 Changed 11 years ago by stuartm

See #5501 for a patch converting libmythtv threads.

comment:6 Changed 10 years ago by stuartm

Milestone: 0.220.23

comment:7 Changed 10 years ago by stuartm

Component: mythtvMythTV - General

comment:8 Changed 9 years ago by paulh

Milestone: 0.230.24

This will have to wait for 0.24

comment:9 Changed 9 years ago by robertm

Milestone: 0.24unknown
Owner: Isaac Richards deleted
Status: acceptednew

There's a lot of pthread stuff still remainin in mythxml/web server. Nobody has touched this in ages. Unassigning and bumping to unknown.

comment:10 Changed 9 years ago by beirdo

Owner: set to beirdo
Status: newassigned

comment:11 Changed 8 years ago by beirdo

Converted the thread in DeviceReadBuffer? in dfa4ea701dcaf on master

comment:12 Changed 8 years ago by beirdo

Converted the threads in ThreadedFileWriter? in 482299ae1b12fe on master

comment:13 Changed 8 years ago by beirdo

Converted the ddMapLoad thread in TV in 7aace953aa36 on master

comment:14 Changed 8 years ago by beirdo

Converted the TVRec threads (event and recording) in a5a2a9c0192f on master

comment:15 Changed 8 years ago by Gavin Hurlbut

Converted the OSX Controller Thread to QThread

Refs #5501, I converted the Firewire Controller thread from pthread to QThread. This is only for the OSX firewire support, which I can not test for lack of compatible hardware.

Changeset: 50f58070dc7caec760f3c14667b19d97c2630340

comment:16 Changed 8 years ago by Gavin Hurlbut

Convert Linux FireWire? Controller Thread to QThread

Refs #5501. Converted the Linux FireWire? controller thread from pthread to QThread. As I have no firewire setup, I can not test this.

Changeset: 07dd9d2cb6a1a87d62a90dac8a994b0c16792669

comment:17 Changed 8 years ago by Gavin Hurlbut

Converted firewire signal monitor thread to QThread

Refs #5501. I have converted the firewire signal monitor thread from pthread to QThread. I have no way to test this past compilation.

Changeset: 90d5712719ad1d2c3571d0564e582333aa77a8f3

comment:18 Changed 8 years ago by Gavin Hurlbut

Convert the DVB CI Handler thread to QThread

Refs #5501. I have converted the DVB CI Handler thread from pthread to QThread. I have no way of testing this.

Changeset: 2d86cea00f88f96278140ada5f5b4c9fe7dbcab6

comment:19 Changed 8 years ago by Gavin Hurlbut

Converted IPTVSignalMonitor thread to QThread

Refs #5501. Converted the thread in IPTVSignalMonitor from pthread to QThread. I have no way of testing this, having no IPTV source available.

Changeset: ff9606a53442380a8d128756658cd37657087608

comment:20 Changed 8 years ago by zeloise@…

CI is not working after commit 2d86cea00f88f96278140ada5f5b4c9fe7dbcab6

comment:21 Changed 8 years ago by beirdo

Sorry to hear that. Can you possibly give me information (log files, etc) to help me fix the problem?

comment:22 Changed 8 years ago by Gavin Hurlbut

Convert SignalMonitor?'s thread to QThread

Refs #5501. Converted the SignalLoopThread? from pthread to QThread. As this is in the base class for all of the SignalMonitors?, this had a small ripple effect.

Changeset: b1649e3b650b9e3f2338f42e5c81c0f68aed2d4a

comment:23 Changed 8 years ago by Gavin Hurlbut

Converted jobqueue threads to QThread

Refs #5501. I have converted the threads used in the jobqueue from pthreads to QThreads. There may be a small memory leak caused by the use of deleteLater in the ChildJobThread? and having no event queue in the QueueProcessorThread?. We'll keep our eyes on it.

Changeset: 361f213a2e0a82f0465d28b731ab472a2f47c482

comment:24 Changed 8 years ago by Gavin Hurlbut

Convert MHEG Engine Thread to QThread

Refs #5501. Converted the MHEG Engine thread from pthread to QThread. I have no way to test this past compile.

Changeset: eb7d2bdffcfda1789248786d4bacf9cbc6958649

comment:25 Changed 8 years ago by Gavin Hurlbut

Convert NuppelVideoRecorder? threads to QThreads

Refs #5501. I have converted the three threads (Write, Audio and VBI) within NuppelVideoRecorder? to using QThreads rather than directly using pthreads.

Changeset: 72f13d4b264927175ac0a20fb8e880a80750bc0e

comment:26 Changed 8 years ago by Gavin Hurlbut

Convert MPEG2replex thread to QThread

Refs #5501. Convert the MPEG2replex thread from pthread to QThread. Additionally, convert the corresponding pthread_mutex and pthread_cond to QMutex and QWaitCondition respectively. I also moved the thread into the MPEG2replex class with the mutex/condvar to make it easier to deal with.

Changeset: cee4487fdaec46c66ad1f5f60e35e0db96736e0f

comment:27 Changed 8 years ago by Gavin Hurlbut

Change NetworkCommandThread? in mythfrontend to QThread

Refs #5501. Converted the NetworkCommandThread? from pthread to QThread. Also removed the unused SocketThread?() and RunSocketThread?() methods from NetworkControl? as they are unused.

Changeset: 1140e4f45d81653f439672586eb55fb3533be16c

comment:28 in reply to:  21 Changed 8 years ago by zeloise@…

Replying to beirdo:

Sorry to hear that. Can you possibly give me information (log files, etc) to help me fix the problem?

Hello Beirdo

I confirm that the problem has been solved with the following commits:

  • b584b689422b25aebca7: Fix the DVBCam::IsRunning?() to use thread running (2011-03-10)
  • 1e0e5091a6d5949ceb80: Check ciHandler for NULL before use since it may not be set if DVBCam::Start() fails and we don't check the return of that function in DVBChannel. (2011-03-10)

Thanks for your helps zeloise

comment:29 Changed 8 years ago by beirdo

Owner: changed from beirdo to danielk

I am giving this ticket to danielk as he has reverted some of the changes so they can be redone.

Changed 8 years ago by danielk

Attachment: mthread-v1.patch added

Work in progress..

comment:30 Changed 8 years ago by danielk

Summary: Convert pthreads -> QthreadConvert pthreads -> Mthread

The attached patch creates MThread and MThreadPool and converts to their use throughout.

They provide basically the same interface as the Qt classes they are named after, but shutdown DB connections for us and provide additional safety over the Qt classes via simple sanity checks.

Only mythfrontend has had any testing.

Changed 8 years ago by danielk

Attachment: mthread-v2.patch added

Now the plugins also compile + misc fixes.

Changed 8 years ago by danielk

Attachment: mthread-v3.patch added

comment:31 Changed 8 years ago by danielk

  • Cleans up some header includes (sed left "mthread.h" with the Qt headers)
  • Changes MThreadPool API in two ways:
    • Gets rid of start() methods without a debug name, so we always have something descriptive for threadRegister().
    • Gets rid of reserveThread() and releaseThread(). When we start a long lived runnable with a reservation there is no reason not to start it right away; these methods never guarantee that behavior. A new startReserved() call starts the runnable immediately and increments the reserve thread count and then the reserve thread count is automatically decremented when this runnable finishes.
  • Adds some debugging to MThreads so you can now query the running threads and adds a MThread::Cleanup() method which attempts to shutdown all running threads. This is intended to be used as a last ditch effort in the MythCoreContext? destructor at the point at which no threads should other than the main one should be running. It also prints out a listing of all the threads that are running that shouldn't be ; using the debug name required in the constructor.

Changed 8 years ago by danielk

Attachment: mthread-v4.patch added

Changed 8 years ago by danielk

Attachment: mthread-v5.patch added

fix segfault on myth system thread shutdown when they weren't started in the first place.

Changed 8 years ago by beirdo

Additional patch (goes with mthread-v5) to change new mythgallery filter thread to mthread

Changed 8 years ago by danielk

Attachment: mthread-v6.patch added

Converts new mythgallery thread to MThread, fixes static DB connection cleanup.

Changed 8 years ago by danielk

Attachment: mthread-v7.patch added

Reuses DB connection on a per thread basis

Changed 8 years ago by danielk

Attachment: mthread-v8.patch added

fix purge db conections object's ownership

Changed 8 years ago by danielk

Attachment: mthread-v10.patch.bz2 added

Converts various threadpools to MThreadPool and fixes the MThreadPool tracking for StopAllPools?()/ShutdownAllPools?()

comment:32 Changed 8 years ago by danielk

Note the patch was applied in [47d67e67], but please use at least [b39d35a4].

comment:33 Changed 8 years ago by danielk

Note: A fix for the static initialization of the logger and mythsockethread static initializers was applied in [f4ba7827].

comment:34 Changed 8 years ago by Github

Refs #5501. Convert DDMapLoader thread to use MThreadPool.

Branch: master Changeset: aa1038ca75dde6117fe873a030734b4246e5ca5a

comment:35 Changed 8 years ago by danielk

Resolution: Fixed
Status: assignedclosed

I'm closing this ticket. The only remaining pthread code is:

jobqueue, a detached thread which can't be implemented with MThread/QThread darwindfirewiredevice.cpp, a special hardware specific thread on a platform with pthreads mpeg2fix.cpp, which uses pthread wake one semantics.

And some imported code where we want upstream compatibility. Of those only mpeg2fix is really a candidate for porting.

Many of our threads don't use the Qt event loop, so event driven Qt classes won't work properly in those threads, but that is a separate issue. All the threads now using MThread will no longer have problems with thread local storage, which prevented things like QRegExp from working efficiently.

Note: See TracTickets for help on using tickets.