forked from qt-creator/qt-creator
TaskTree: Replace the usages of old WaitFor with new Barrier
Adapt the TaskTree tests and the usage in FileStreamer. The FileStreamer may be tested by running the FileSystemAccessTest. Change-Id: I1d8086dd359c458b7bdd3d4d47cf249184b04c65 Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include "filestreamer.h"
|
||||
|
||||
#include "asynctask.h"
|
||||
#include "barrier.h"
|
||||
#include "qtcprocess.h"
|
||||
|
||||
#include <QFile>
|
||||
@@ -321,7 +322,7 @@ static Group sameRemoteDeviceTransferTask(const FilePath &source, const FilePath
|
||||
static Group interDeviceTransferTask(const FilePath &source, const FilePath &destination)
|
||||
{
|
||||
struct TransferStorage { QPointer<FileStreamWriter> writer; };
|
||||
Condition condition;
|
||||
SingleBarrier writerReadyBarrier;
|
||||
TreeStorage<TransferStorage> storage;
|
||||
|
||||
const auto setupReader = [=](FileStreamReader &reader) {
|
||||
@@ -336,19 +337,19 @@ static Group interDeviceTransferTask(const FilePath &source, const FilePath &des
|
||||
};
|
||||
const auto setupWriter = [=](FileStreamWriter &writer) {
|
||||
writer.setFilePath(destination);
|
||||
ConditionActivator *activator = condition.activator();
|
||||
QObject::connect(&writer, &FileStreamWriter::started,
|
||||
&writer, [activator] { activator->activate(); });
|
||||
writerReadyBarrier->barrier(), &Barrier::advance);
|
||||
QTC_CHECK(storage->writer == nullptr);
|
||||
storage->writer = &writer;
|
||||
};
|
||||
|
||||
const Group root {
|
||||
Storage(writerReadyBarrier),
|
||||
parallel,
|
||||
Storage(storage),
|
||||
Writer(setupWriter),
|
||||
Group {
|
||||
WaitFor(condition),
|
||||
WaitForBarrier(writerReadyBarrier),
|
||||
Reader(setupReader, finalizeReader, finalizeReader)
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user