Anyway i'll do it with custom class based on QObject and my signals from thread working.
for (int i = 0; i < idealThreadCount; ++i) {
MyClass *myclass = new MyClass;
connect(progress.data(), SIGNAL(canceled()), myclass, SLOT(cancel()));
connect(myclass, SIGNAL(step()), this, SLOT(stepChanged()));
QFuture <void> future = QtConcurrent::run(myclass, &MyClass::run, offset, blockSize, (quint32)-1);
//there is need place QFuture to outside container
for (int i = 0; i < idealThreadCount; ++i) {
MyClass *myclass = new MyClass;
connect(progress.data(), SIGNAL(canceled()), myclass, SLOT(cancel()));
connect(myclass, SIGNAL(step()), this, SLOT(stepChanged()));
QFuture <void> future = QtConcurrent::run(myclass, &MyClass::run, offset, blockSize, (quint32)-1);
//there is need place QFuture to outside container
To copy to clipboard, switch view to plain text mode
qint32 MyClass::run(quint32 start, qint32 count, quint32 total)
{
for (int i = 0, j = (total/100)*1; i < count; ++i, ++start) {
if (!isCanceled()) {
if (i % j == 0) {
emit step();
qDebug
() << j << i << start << count <<
QThread::currentThreadId() << thread
();
}
} else {
break;
}
}
deleteLater();
return 0;
}
qint32 MyClass::run(quint32 start, qint32 count, quint32 total)
{
for (int i = 0, j = (total/100)*1; i < count; ++i, ++start) {
if (!isCanceled()) {
if (i % j == 0) {
emit step();
qDebug() << j << i << start << count << QThread::currentThreadId() << thread();
}
} else {
break;
}
}
deleteLater();
return 0;
}
To copy to clipboard, switch view to plain text mode
There is another problem, how to distribute count of operation on cores if devide operation on cores don't get integer without remainder. So i need somehow distribute this remainder on operations.
Bookmarks