Database::Database( const QString& dbname, QObject* parent ) : QObject( parent ) , m_ready( false ) , m_impl( new DatabaseImpl( dbname ) ) , m_workerRW( new DatabaseWorkerThread( this, true ) ) , m_idWorker( new IdThreadWorker( this ) ) { s_instance = this; if ( MAX_WORKER_THREADS < DEFAULT_WORKER_THREADS ) m_maxConcurrentThreads = MAX_WORKER_THREADS; else m_maxConcurrentThreads = qBound( DEFAULT_WORKER_THREADS, QThread::idealThreadCount(), MAX_WORKER_THREADS ); tDebug() << Q_FUNC_INFO << "Using" << m_maxConcurrentThreads << "database worker threads"; connect( m_impl, SIGNAL( indexReady() ), SIGNAL( indexReady() ) ); connect( m_impl, SIGNAL( indexReady() ), SIGNAL( ready() ) ); connect( m_impl, SIGNAL( indexReady() ), SLOT( setIsReadyTrue() ) ); Q_ASSERT( m_workerRW ); m_workerRW.data()->start(); while ( m_workerThreads.count() < m_maxConcurrentThreads ) { QPointer< DatabaseWorkerThread > workerThread( new DatabaseWorkerThread( this, false ) ); Q_ASSERT( workerThread ); workerThread.data()->start(); m_workerThreads << workerThread; } m_idWorker->start(); }
Database::Database( const QString& dbname, QObject* parent ) : QObject( parent ) , m_ready( false ) , m_impl( new DatabaseImpl( dbname, this ) ) , m_workerRW( new DatabaseWorker( m_impl, this, true ) ) { s_instance = this; m_maxConcurrentThreads = qBound( DEFAULT_WORKER_THREADS, QThread::idealThreadCount(), MAX_WORKER_THREADS ); qDebug() << Q_FUNC_INFO << "Using" << m_maxConcurrentThreads << "threads"; connect( m_impl, SIGNAL( indexReady() ), SIGNAL( indexReady() ) ); connect( m_impl, SIGNAL( indexReady() ), SIGNAL( ready() ) ); connect( m_impl, SIGNAL( indexReady() ), SLOT( setIsReadyTrue() ) ); m_workerRW->start(); }