TaskTree: Qt-ify the code (part 2)

6. Drop #pragma once header guides.
7. Remove trailing semicolons after Q_ENUM_NS.
8. Use QT_CONFIG(process) for QProcessTask.
9. Update copyright headers.
10. Enclose all classes into Qt namespace.

Amends 6621c68ca9

Change-Id: I42df9a04b029a65d025699eb02fd9f3d1c1a333a
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2024-06-07 10:28:21 +02:00
parent cb0bedc49d
commit 88ee3aa908
12 changed files with 111 additions and 24 deletions

View File

@@ -1,8 +1,11 @@
// Copyright (C) 2023 The Qt Company Ltd.
// Copyright (C) 2024 Jarek Kobus
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "barrier.h"
QT_BEGIN_NAMESPACE
namespace Tasking {
// That's cut down qtcassert.{c,h} to avoid the dependency.
@@ -47,3 +50,5 @@ void Barrier::stopWithResult(DoneResult result)
}
} // namespace Tasking
QT_END_NAMESPACE

View File

@@ -1,12 +1,16 @@
// Copyright (C) 2023 The Qt Company Ltd.
// Copyright (C) 2024 Jarek Kobus
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#ifndef TASKING_BARRIER_H
#define TASKING_BARRIER_H
#include "tasking_global.h"
#include "tasktree.h"
QT_BEGIN_NAMESPACE
namespace Tasking {
class TASKING_EXPORT Barrier final : public QObject
@@ -91,3 +95,7 @@ GroupItem waitForBarrierTask(const MultiBarrier<Limit> &sharedBarrier)
}
} // namespace Tasking
QT_END_NAMESPACE
#endif // TASKING_BARRIER_H

View File

@@ -1,12 +1,16 @@
// Copyright (C) 2023 The Qt Company Ltd.
// Copyright (C) 2024 Jarek Kobus
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#ifndef TASKING_CONCURRENTCALL_H
#define TASKING_CONCURRENTCALL_H
#include "tasktree.h"
#include <QtConcurrent/QtConcurrent>
QT_BEGIN_NAMESPACE
namespace Tasking {
// This class introduces the dependency to Qt::Concurrent, otherwise Tasking namespace
@@ -98,3 +102,7 @@ template <typename T>
using ConcurrentCallTask = CustomTask<ConcurrentCallTaskAdapter<T>>;
} // namespace Tasking
QT_END_NAMESPACE
#endif // TASKING_CONCURRENTCALL_H

View File

@@ -1,10 +1,13 @@
// Copyright (C) 2023 The Qt Company Ltd.
// Copyright (C) 2024 Jarek Kobus
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "networkquery.h"
#include <QtNetwork/QNetworkAccessManager>
QT_BEGIN_NAMESPACE
namespace Tasking {
void NetworkQuery::start()
@@ -51,3 +54,5 @@ NetworkQuery::~NetworkQuery()
}
} // namespace Tasking
QT_END_NAMESPACE

View File

@@ -1,7 +1,9 @@
// Copyright (C) 2023 The Qt Company Ltd.
// Copyright (C) 2024 Jarek Kobus
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#pragma once
#ifndef TASKING_NETWORKQUERY_H
#define TASKING_NETWORKQUERY_H
#include "tasking_global.h"
@@ -14,7 +16,6 @@
QT_BEGIN_NAMESPACE
class QNetworkAccessManager;
QT_END_NAMESPACE
namespace Tasking {
@@ -59,3 +60,7 @@ public:
using NetworkQueryTask = CustomTask<NetworkQueryTaskAdapter>;
} // namespace Tasking
QT_END_NAMESPACE
#endif // TASKING_NETWORKQUERY_H

View File

@@ -1,4 +1,5 @@
// Copyright (C) 2023 The Qt Company Ltd.
// Copyright (C) 2024 Jarek Kobus
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "qprocesstask.h"
@@ -10,6 +11,10 @@
#include <QtCore/QTimer>
#include <QtCore/QWaitCondition>
QT_BEGIN_NAMESPACE
#if QT_CONFIG(process)
namespace Tasking {
class ProcessReaperPrivate;
@@ -262,4 +267,13 @@ void QProcessDeleter::operator()(QProcess *process)
} // namespace Tasking
#endif // QT_CONFIG(process)
QT_END_NAMESPACE
#if QT_CONFIG(process)
#include "qprocesstask.moc"
#endif // QT_CONFIG(process)

View File

@@ -1,7 +1,9 @@
// Copyright (C) 2023 The Qt Company Ltd.
// Copyright (C) 2024 Jarek Kobus
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#ifndef TASKING_QPROCESSTASK_H
#define TASKING_QPROCESSTASK_H
#include "tasking_global.h"
@@ -9,6 +11,10 @@
#include <QtCore/QProcess>
QT_BEGIN_NAMESPACE
#if QT_CONFIG(process)
namespace Tasking {
// Deleting a running QProcess may block the caller thread up to 30 seconds and issue warnings.
@@ -64,3 +70,9 @@ private:
using QProcessTask = CustomTask<QProcessAdapter>;
} // namespace Tasking
#endif // QT_CONFIG(process)
QT_END_NAMESPACE
#endif // TASKING_QPROCESSTASK_H

View File

@@ -1,10 +1,13 @@
// Copyright (C) 2023 The Qt Company Ltd.
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#ifndef TASKING_GLOBAL_H
#define TASKING_GLOBAL_H
#include <QtCore/qglobal.h>
QT_BEGIN_NAMESPACE
#if defined(TASKING_LIBRARY)
# define TASKING_EXPORT Q_DECL_EXPORT
#elif defined(TASKING_STATIC_LIBRARY)
@@ -12,3 +15,7 @@
#else
# define TASKING_EXPORT Q_DECL_IMPORT
#endif
QT_END_NAMESPACE
#endif // TASKING_GLOBAL_H

View File

@@ -1,4 +1,5 @@
// Copyright (C) 2023 The Qt Company Ltd.
// Copyright (C) 2024 Jarek Kobus
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "tasktree.h"
@@ -19,6 +20,8 @@
using namespace std::chrono;
QT_BEGIN_NAMESPACE
namespace Tasking {
// That's cut down qtcassert.{c,h} to avoid the dependency.
@@ -3415,3 +3418,5 @@ void TimeoutTaskAdapter::start()
*/
} // namespace Tasking
QT_END_NAMESPACE

View File

@@ -1,7 +1,9 @@
// Copyright (C) 2023 The Qt Company Ltd.
// Copyright (C) 2024 Jarek Kobus
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#ifndef TASKING_TASKTREE_H
#define TASKING_TASKTREE_H
#include "tasking_global.h"
@@ -13,7 +15,6 @@
QT_BEGIN_NAMESPACE
template <class T>
class QFuture;
QT_END_NAMESPACE
namespace Tasking {
@@ -41,7 +42,7 @@ enum class WorkflowPolicy
FinishAllAndSuccess, // 4 - Reports success after all children finished.
FinishAllAndError // 5 - Reports error after all children finished.
};
Q_ENUM_NS(WorkflowPolicy);
Q_ENUM_NS(WorkflowPolicy)
enum class SetupResult
{
@@ -49,14 +50,14 @@ enum class SetupResult
StopWithSuccess,
StopWithError
};
Q_ENUM_NS(SetupResult);
Q_ENUM_NS(SetupResult)
enum class DoneResult
{
Success,
Error
};
Q_ENUM_NS(DoneResult);
Q_ENUM_NS(DoneResult)
enum class DoneWith
{
@@ -64,7 +65,7 @@ enum class DoneWith
Error,
Cancel
};
Q_ENUM_NS(DoneWith);
Q_ENUM_NS(DoneWith)
enum class CallDoneIf
{
@@ -72,7 +73,7 @@ enum class CallDoneIf
Success,
Error
};
Q_ENUM_NS(CallDoneIf);
Q_ENUM_NS(CallDoneIf)
TASKING_EXPORT DoneResult toDoneResult(bool success);
@@ -624,3 +625,7 @@ using TaskTreeTask = CustomTask<TaskTreeTaskAdapter>;
using TimeoutTask = CustomTask<TimeoutTaskAdapter>;
} // namespace Tasking
QT_END_NAMESPACE
#endif // TASKING_TASKTREE_H

View File

@@ -1,3 +1,4 @@
// Copyright (C) 2024 Jarek Kobus
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
@@ -5,6 +6,8 @@
#include "tasktree.h"
QT_BEGIN_NAMESPACE
namespace Tasking {
TaskTreeRunner::~TaskTreeRunner() = default;
@@ -38,3 +41,5 @@ void TaskTreeRunner::reset()
}
} // namespace Tasking
QT_END_NAMESPACE

View File

@@ -1,13 +1,17 @@
// Copyright (C) 2024 Jarek Kobus
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#ifndef TASKING_TASKTREERUNNER_H
#define TASKING_TASKTREERUNNER_H
#include "tasking_global.h"
#include "tasktree.h"
#include <QtCore/QObject>
QT_BEGIN_NAMESPACE
namespace Tasking {
class TASKING_EXPORT TaskTreeRunner : public QObject
@@ -42,3 +46,7 @@ private:
};
} // namespace Tasking
QT_END_NAMESPACE
#endif // TASKING_TASKTREERUNNER_H