Qt 4.8
Public Functions | Public Variables | List of all members
QFutureInterfaceBasePrivate Class Reference

#include <qfutureinterface_p.h>

Public Functions

void connectOutputInterface (QFutureCallOutInterface *iface)
 
void disconnectOutputInterface (QFutureCallOutInterface *iface)
 
bool internal_isResultReadyAt (int index) const
 
int internal_resultCount () const
 
void internal_setThrottled (bool enable)
 
bool internal_updateProgress (int progress, const QString &progressText=QString())
 
bool internal_waitForNextResult ()
 
 QFutureInterfaceBasePrivate (QFutureInterfaceBase::State initialState)
 
void sendCallOut (const QFutureCallOutEvent &callOut)
 
void sendCallOuts (const QFutureCallOutEvent &callOut1, const QFutureCallOutEvent &callOut2)
 
void setState (QFutureInterfaceBase::State state)
 

Public Variables

QtConcurrent::internal::ExceptionStore m_exceptionStore
 
int m_expectedResultCount
 
QMutex m_mutex
 
int m_progressMaximum
 
int m_progressMinimum
 
QString m_progressText
 
int m_progressValue
 
QtConcurrent::ResultStoreBase m_results
 
bool manualProgress
 
QList< QFutureCallOutInterface * > outputConnections
 
QWaitCondition pausedWaitCondition
 
int pendingResults
 
QElapsedTimer progressTime
 
QAtomicInt refCount
 
QRunnablerunnable
 
QFutureInterfaceBase::State state
 
QWaitCondition waitCondition
 

Detailed Description

Definition at line 127 of file qfutureinterface_p.h.

Constructors and Destructors

◆ QFutureInterfaceBasePrivate()

QFutureInterfaceBasePrivate::QFutureInterfaceBasePrivate ( QFutureInterfaceBase::State  initialState)

Functions

◆ connectOutputInterface()

void QFutureInterfaceBasePrivate::connectOutputInterface ( QFutureCallOutInterface iface)

Definition at line 511 of file qfutureinterface.cpp.

512 {
513  QMutexLocker locker(&m_mutex);
514 
516  interface->postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::Started));
517  interface->postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::ProgressRange,
520  interface->postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::Progress,
522  m_progressText));
523  }
524 
525  QtConcurrent::ResultIteratorBase it = m_results.begin();
526  while (it != m_results.end()) {
527  const int begin = it.resultIndex();
528  const int end = begin + it.batchSize();
529  interface->postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::ResultsReady,
530  begin,
531  end));
532  it.batchedAdvance();
533  }
534 
536  interface->postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::Paused));
537 
539  interface->postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::Canceled));
540 
542  interface->postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::Finished));
543 
544  outputConnections.append(interface);
545 }
#define it(className, varName)
QtConcurrent::ResultStoreBase m_results
QFutureInterfaceBase::State state
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
QList< QFutureCallOutInterface * > outputConnections
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
static const KeyPair *const end

◆ disconnectOutputInterface()

void QFutureInterfaceBasePrivate::disconnectOutputInterface ( QFutureCallOutInterface iface)

Definition at line 547 of file qfutureinterface.cpp.

548 {
550  const int index = outputConnections.indexOf(interface);
551  if (index == -1)
552  return;
554 
555  interface->callOutInterfaceDisconnected();
556 }
QList< QFutureCallOutInterface * > outputConnections
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
int indexOf(const T &t, int from=0) const
Returns the index position of the first occurrence of value in the list, searching forward from index...
Definition: qlist.h:847
static QReadWriteLock lock
Definition: proxyconf.cpp:399
quint16 index
void removeAt(int i)
Removes the item at index position i.
Definition: qlist.h:480

◆ internal_isResultReadyAt()

bool QFutureInterfaceBasePrivate::internal_isResultReadyAt ( int  index) const

Definition at line 435 of file qfutureinterface.cpp.

Referenced by QFutureInterfaceBase::isResultReadyAt(), and QFutureInterfaceBase::waitForResult().

436 {
437  return (m_results.contains(index));
438 }
QtConcurrent::ResultStoreBase m_results
quint16 index

◆ internal_resultCount()

int QFutureInterfaceBasePrivate::internal_resultCount ( ) const

Definition at line 430 of file qfutureinterface.cpp.

Referenced by QFutureInterfaceBase::resultCount().

431 {
432  return m_results.count(); // ### subtract canceled results.
433 }
QtConcurrent::ResultStoreBase m_results

◆ internal_setThrottled()

void QFutureInterfaceBasePrivate::internal_setThrottled ( bool  enable)

Definition at line 468 of file qfutureinterface.cpp.

469 {
470  // bail out if we are not changing the state
471  if ((enable && (state & QFutureInterfaceBase::Throttled))
472  || (!enable && !(state & QFutureInterfaceBase::Throttled)))
473  return;
474 
475  // change the state
476  if (enable) {
477  state = QFutureInterfaceBase::State(state | QFutureInterfaceBase::Throttled);
478  } else {
479  state = QFutureInterfaceBase::State(state & ~QFutureInterfaceBase::Throttled);
482  }
483 }
QFutureInterfaceBase::State state

◆ internal_updateProgress()

bool QFutureInterfaceBasePrivate::internal_updateProgress ( int  progress,
const QString progressText = QString() 
)

Definition at line 451 of file qfutureinterface.cpp.

Referenced by QFutureInterfaceBase::reportResultsReady(), and QFutureInterfaceBase::setProgressValueAndText().

453 {
454  if (m_progressValue >= progress)
455  return false;
456 
457  m_progressValue = progress;
458  m_progressText = progressText;
459 
460  if (progressTime.isValid() && m_progressValue != m_progressMaximum) // make sure the first and last steps are emitted.
462  return false;
463 
465  return true;
466 }
bool isValid() const
Returns false if this object was invalidated by a call to invalidate() and has not been restarted sin...
qint64 elapsed() const
Returns the number of milliseconds since this QElapsedTimer was last started.
void start()
Starts this timer.

◆ internal_waitForNextResult()

bool QFutureInterfaceBasePrivate::internal_waitForNextResult ( )

Definition at line 440 of file qfutureinterface.cpp.

Referenced by QFutureInterfaceBase::waitForNextResult().

441 {
442  if (m_results.hasNextResult())
443  return true;
444 
445  while ((state & QFutureInterfaceBase::Running) && m_results.hasNextResult() == false)
447 
448  return (!(state & QFutureInterfaceBase::Canceled) && m_results.hasNextResult());
449 }
QtConcurrent::ResultStoreBase m_results
QFutureInterfaceBase::State state
bool wait(QMutex *mutex, unsigned long time=ULONG_MAX)

◆ sendCallOut()

void QFutureInterfaceBasePrivate::sendCallOut ( const QFutureCallOutEvent callOut)

Definition at line 485 of file qfutureinterface.cpp.

Referenced by QFutureInterfaceBase::cancel(), QFutureInterfaceBase::reportException(), QFutureInterfaceBase::reportFinished(), QFutureInterfaceBase::reportResultsReady(), QFutureInterfaceBase::reportStarted(), QFutureInterfaceBase::setPaused(), QFutureInterfaceBase::setProgressRange(), QFutureInterfaceBase::setProgressValueAndText(), and QFutureInterfaceBase::togglePaused().

486 {
488  return;
489 
490  for (int i = 0; i < outputConnections.count(); ++i)
491  outputConnections.at(i)->postCallOutEvent(callOutEvent);
492 }
virtual void postCallOutEvent(const QFutureCallOutEvent &)=0
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QList< QFutureCallOutInterface * > outputConnections

◆ sendCallOuts()

void QFutureInterfaceBasePrivate::sendCallOuts ( const QFutureCallOutEvent callOut1,
const QFutureCallOutEvent callOut2 
)

Definition at line 494 of file qfutureinterface.cpp.

Referenced by QFutureInterfaceBase::reportResultsReady().

496 {
498  return;
499 
500  for (int i = 0; i < outputConnections.count(); ++i) {
502  interface->postCallOutEvent(callOutEvent1);
503  interface->postCallOutEvent(callOutEvent2);
504  }
505 }
#define at(className, varName)
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
QList< QFutureCallOutInterface * > outputConnections

◆ setState()

void QFutureInterfaceBasePrivate::setState ( QFutureInterfaceBase::State  state)

Definition at line 558 of file qfutureinterface.cpp.

Referenced by QFutureInterfaceBase::reportStarted().

559 {
560  state = newState;
561 }
QFutureInterfaceBase::State state

Properties

◆ m_exceptionStore

QtConcurrent::internal::ExceptionStore QFutureInterfaceBasePrivate::m_exceptionStore

◆ m_expectedResultCount

int QFutureInterfaceBasePrivate::m_expectedResultCount

◆ m_mutex

QMutex QFutureInterfaceBasePrivate::m_mutex
mutable

◆ m_progressMaximum

int QFutureInterfaceBasePrivate::m_progressMaximum

◆ m_progressMinimum

int QFutureInterfaceBasePrivate::m_progressMinimum

◆ m_progressText

QString QFutureInterfaceBasePrivate::m_progressText

◆ m_progressValue

int QFutureInterfaceBasePrivate::m_progressValue

◆ m_results

QtConcurrent::ResultStoreBase QFutureInterfaceBasePrivate::m_results

◆ manualProgress

bool QFutureInterfaceBasePrivate::manualProgress

◆ outputConnections

QList<QFutureCallOutInterface *> QFutureInterfaceBasePrivate::outputConnections

◆ pausedWaitCondition

QWaitCondition QFutureInterfaceBasePrivate::pausedWaitCondition

◆ pendingResults

int QFutureInterfaceBasePrivate::pendingResults

Definition at line 142 of file qfutureinterface_p.h.

◆ progressTime

QElapsedTimer QFutureInterfaceBasePrivate::progressTime

◆ refCount

QAtomicInt QFutureInterfaceBasePrivate::refCount

◆ runnable

QRunnable* QFutureInterfaceBasePrivate::runnable

◆ state

QFutureInterfaceBase::State QFutureInterfaceBasePrivate::state

◆ waitCondition

QWaitCondition QFutureInterfaceBasePrivate::waitCondition

The documentation for this class was generated from the following files: