[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/work/kde4/extragear/multimedia/amarok/src
From:       Gábor Lehel <illissius () gmail ! com>
Date:       2006-05-31 23:50:19
Message-ID: 1149119419.626211.12136.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 547154 by illissius:

remove the custom thread id stuff, in favor of Qt4's version
some other stuff


 M  +1 -1      collectiondb.cpp  
 M  +11 -3     playlistloader.cpp  
 M  +3 -3      statusbar/statusBarBase.cpp  
 M  +3 -34     threadweaver.cpp  
 M  +3 -27     threadweaver.h  


--- branches/work/kde4/extragear/multimedia/amarok/src/collectiondb.cpp \
#547153:547154 @@ -3560,7 +3560,7 @@
     connectionMutex->lock();
 
     DbConnection *dbConn;
-    QThread *currThread = ThreadWeaver::Thread::getRunning();
+    QThread *currThread = QThread::currentThread();
 
     if (threadConnections->contains(currThread))
     {
--- branches/work/kde4/extragear/multimedia/amarok/src/playlistloader.cpp \
#547153:547154 @@ -80,6 +80,8 @@
 {
     DEBUG_BLOCK
 
+    debug() << "construct!" << endl;
+
     connect( this,                 SIGNAL( queueChanged( const PLItemList &, const \
                PLItemList & ) ),
              Playlist::instance(), SIGNAL( queueChanged( const PLItemList &, const \
PLItemList & ) ) );  
@@ -138,6 +140,7 @@
 
 UrlLoader::~UrlLoader()
 {
+    debug() << "destruct!" << endl;
     Playlist::instance()->unlock();
 
     delete m_markerListViewItem;
@@ -147,6 +150,7 @@
 bool
 UrlLoader::doJob()
 {
+    debug() << "doJob!" << endl;
     setProgressTotalSteps( m_URLs.count() );
 
     KUrl::List urls;
@@ -162,6 +166,10 @@
             loadXml( url );
             break;
 
+        case PlaylistFile::NotPlaylist:
+            (EngineController::canDecode( url ) ? urls : m_badURLs) += url;
+            break;
+
         default: {
             PlaylistFile playlist( url.path() );
 
@@ -171,9 +179,6 @@
                 m_badURLs += url;
 
             } break;
-
-        case PlaylistFile::NotPlaylist:
-            (EngineController::canDecode( url ) ? urls : m_badURLs) += url;
         }
 
         if( urls.count() == OPTIMUM_BUNDLE_COUNT || ( it + 1 ) == end ) {
@@ -188,6 +193,7 @@
 void
 UrlLoader::customEvent( QCustomEvent *e)
 {
+    debug() << "customEvent!" << endl;
     bool atfEnabled = AmarokConfig::advancedTagFeatures();
     #define e static_cast<TagsEvent*>(e)
     switch( e->type() ) {
@@ -254,6 +260,7 @@
 
     default:
         DependentJob::customEvent( e );
+        warning() << "strange custom event!" << endl;
         return;
     }
     #undef e
@@ -262,6 +269,7 @@
 void
 UrlLoader::completeJob()
 {
+    debug() << "completeJob!" << endl;
     const PLItemList &newQueue = Playlist::instance()->m_nextTracks;
     Q3PtrListIterator<PlaylistItem> it( newQueue );
     PLItemList added;
--- branches/work/kde4/extragear/multimedia/amarok/src/statusbar/statusBarBase.cpp \
#547153:547154 @@ -68,14 +68,14 @@
 {
     static void startTimer( int timeout, QObject *receiver, const char *slot )
     {
-        /*QTimer *timer = dynamic_cast<QTimer*>( receiver->child( slot ) );
+        QTimer *timer = dynamic_cast<QTimer*>( receiver->child( slot ) );
         if( !timer ) {
             timer = new QTimer( receiver );
             timer->setObjectName( slot );
             receiver->connect( timer, SIGNAL(timeout()), slot );
         }
 
-        timer->start( timeout, true );*/
+        timer->start( timeout, true );
     }
 
     static inline bool isActive( QObject *parent, const char *slot )
@@ -370,7 +370,7 @@
 
     m_popupProgress->reposition();
     
-//    connect( owner, SIGNAL(destroyed( QObject* )), SLOT(endProgressOperation( \
QObject* )) ); +   connect( owner, SIGNAL(destroyed( QObject* )), \
SLOT(endProgressOperation( QObject* )), Qt::DirectConnection );  
     // so we can show the correct progress information
     // after the ProgressBar is setup
--- branches/work/kde4/extragear/multimedia/amarok/src/threadweaver.cpp \
#547153:547154 @@ -24,9 +24,6 @@
 
 using amaroK::StatusBar;
 
-volatile uint ThreadWeaver::threadIdCounter = 1; //main thread grabs zero
-QMutex* ThreadWeaver::threadIdMutex = new QMutex();
-
 ThreadWeaver::ThreadWeaver()
 {
     startTimer( 5 * 60 * 1000 ); // prunes the thread pool every 5 minutes
@@ -212,11 +209,6 @@
 }
 
 
-//Taken from Qt 4 src/corelib/thread/qthread_unix.cpp
-static pthread_once_t current_thread_key_once = PTHREAD_ONCE_INIT;
-static pthread_key_t current_thread_key;
-static void create_current_thread_key()
-{ debug() << "Creating pthread key, exit value is " << \
pthread_key_create(&current_thread_key, NULL) << endl; }  /// @class \
ThreadWeaver::Thread  
 ThreadWeaver::Thread::Thread()
@@ -229,37 +221,19 @@
     Q_ASSERT( isFinished() );
 }
 
-QThread*
-ThreadWeaver::Thread::getRunning()
-{
-    pthread_once( &current_thread_key_once, create_current_thread_key );
-    return reinterpret_cast<QThread *>( pthread_getspecific( current_thread_key ) );
-}
-
-QString
-ThreadWeaver::Thread::threadId()
-{
-    if( !getRunning() )
-        return "None";
-    else
-    {
-        QString s;
-        return s.sprintf( "%p", getRunning() );
-    }
-}
-
 void
 ThreadWeaver::Thread::runJob( Job *job )
 {
     job->m_thread = this;
-    job->m_parentThreadId = m_threadId;
 
     if ( job->isAborted() )
         QApplication::postEvent( ThreadWeaver::instance(), job );
 
     else {
         m_job = job;
-        start( Thread::IdlePriority ); //will wait() first if necessary
+        if( isRunning() )
+            wait();
+        start( Thread::IdlePriority );
 
         QApplication::postEvent(
                 ThreadWeaver::instance(),
@@ -278,11 +252,6 @@
     if ( AmarokConfig::databaseEngine().toInt() == DbConnection::sqlite )
         CollectionDB::instance()->releasePreviousConnection(this);
 
-    //register this thread so that it can be returned in a static getRunning() \
                function
-    m_threadId = ThreadWeaver::getNewThreadId();
-    pthread_once(&current_thread_key_once, create_current_thread_key);
-    pthread_setspecific(current_thread_key, this);
-
     m_job->m_aborted |= !m_job->doJob();
 
     if( m_job )
--- branches/work/kde4/extragear/multimedia/amarok/src/threadweaver.h #547153:547154
@@ -101,10 +101,6 @@
     static ThreadWeaver *instance();
     static void deleteInstance();
 
-    static volatile uint getNewThreadId();
-    static QMutex *threadIdMutex;
-    static volatile uint threadIdCounter;
-
     /**
      * If the ThreadWeaver is already handling a job of this type then the job
      * will be queued, otherwise the job will be processed immediately. Allocate
@@ -195,15 +191,9 @@
 
         Job *job() const { return m_job; }
 
-        static QThread* getRunning();
-        static QString  threadId();
-        const uint localThreadId() const { return m_threadId; }
-
     private:
         Job *m_job;
 
-        uint m_threadId;
-
         //private so I don't break something in the distant future
         ~Thread();
 
@@ -308,8 +298,6 @@
          */
         //void setVisible( bool );
 
-        uint parentThreadId() { return m_parentThreadId; }
-
     protected:
         /**
          * Executed inside the thread, this should be reimplemented to do the
@@ -336,8 +324,6 @@
         uint m_percentDone;
         uint m_progressDone;
         uint m_totalSteps;
-        uint m_parentThreadId;
-
         QString m_description;
         QString m_status;
 
@@ -397,11 +383,11 @@
 };
 
 //useful debug thingy
-#define DEBUG_THREAD_FUNC_INFO kDebug() << Debug::indent() << k_funcinfo << "thread: \
" << ThreadWeaver::Thread::threadId() << endl; +#define DEBUG_THREAD_FUNC_INFO \
kDebug() << Debug::indent() << k_funcinfo << "thread: " << long( \
QThread::currentThread() ) << endl;  
-#define SHOULD_BE_GUI if( ThreadWeaver::Thread::getRunning() ) std::cout \
+#define SHOULD_BE_GUI if( QThread::currentThread() != \
QCoreApplication::instance()->thread() ) std::cout \  << "Should not be Threaded, but \
                is running in" << \
-    long(ThreadWeaver::Thread::getRunning()) <<std::endl;
+    long (QThread::currentThread()) <<std::endl;
 
 inline ThreadWeaver*
 ThreadWeaver::instance()
@@ -417,14 +403,4 @@
     delete instance();
 }
 
-inline volatile uint
-ThreadWeaver::getNewThreadId()
-{
-    uint temp;
-    threadIdMutex->lock();
-    temp = threadIdCounter++;
-    threadIdMutex->unlock();
-    return temp;
-}
-
 #endif


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic