Skip to content

Commit

Permalink
Initial port
Browse files Browse the repository at this point in the history
  • Loading branch information
cproc committed Dec 10, 2024
1 parent 923bdfd commit eeaadbf
Show file tree
Hide file tree
Showing 5,095 changed files with 824,571 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
20 changes: 20 additions & 0 deletions include/QtConcurrent/QtConcurrent
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef QT_QTCONCURRENT_MODULE_H
#define QT_QTCONCURRENT_MODULE_H
#include <QtConcurrent/QtConcurrentDepends>
#include "qtaskbuilder.h"
#include "qtconcurrentcompilertest.h"
#include "qtconcurrentfilter.h"
#include "qtconcurrentfilterkernel.h"
#include "qtconcurrentfunctionwrappers.h"
#include "qtconcurrentiteratekernel.h"
#include "qtconcurrentmap.h"
#include "qtconcurrentmapkernel.h"
#include "qtconcurrentmedian.h"
#include "qtconcurrentreducekernel.h"
#include "qtconcurrentrun.h"
#include "qtconcurrentrunbase.h"
#include "qtconcurrentstoredfunctioncall.h"
#include "qtconcurrenttask.h"
#include "qtconcurrentthreadengine.h"
#include "qtconcurrentversion.h"
#endif
4 changes: 4 additions & 0 deletions include/QtConcurrent/QtConcurrentDepends
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* This file was generated by cmake with the info from Concurrent target. */
#ifdef __cplusplus /* create empty PCH in C mode */
# include <QtCore/QtCore>
#endif
1 change: 1 addition & 0 deletions include/QtConcurrent/QtConcurrentFilter
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "qtconcurrentfilter.h"
1 change: 1 addition & 0 deletions include/QtConcurrent/QtConcurrentMap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "qtconcurrentmap.h"
1 change: 1 addition & 0 deletions include/QtConcurrent/QtConcurrentRun
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "qtconcurrentrun.h"
1 change: 1 addition & 0 deletions include/QtConcurrent/QtConcurrentVersion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "qtconcurrentversion.h"
135 changes: 135 additions & 0 deletions include/QtConcurrent/qtaskbuilder.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
// Copyright (C) 2020 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#ifndef QTBASE_QTTASKBUILDER_H
#define QTBASE_QTTASKBUILDER_H

#if !defined(QT_NO_CONCURRENT) || defined(Q_QDOC)

#include <QtConcurrent/qtconcurrentstoredfunctioncall.h>

QT_BEGIN_NAMESPACE

#ifdef Q_QDOC

namespace QtConcurrent {

enum class FutureResult { Ignore };

using InvokeResultType = int;

template <class Task, class ...Args>
class QTaskBuilder
{
public:
[[nodiscard]]
QFuture<InvokeResultType> spawn();

void spawn(FutureResult);

template <class ...ExtraArgs>
[[nodiscard]]
QTaskBuilder<Task, ExtraArgs...> withArguments(ExtraArgs &&...args);

[[nodiscard]]
QTaskBuilder<Task, Args...> &onThreadPool(QThreadPool &newThreadPool);

[[nodiscard]]
QTaskBuilder<Task, Args...> &withPriority(int newPriority);
};

} // namespace QtConcurrent

#else

namespace QtConcurrent {

enum class FutureResult { Ignore };

template <class Task, class ...Args>
class QTaskBuilder
{
public:
[[nodiscard]]
auto spawn()
{
return TaskResolver<std::decay_t<Task>, std::decay_t<Args>...>::run(
std::move(taskWithArgs), startParameters);
}

// We don't want to run with promise when we don't return a QFuture
void spawn(FutureResult)
{
(new StoredFunctionCall<Task, Args...>(std::move(taskWithArgs)))
->start(startParameters);
}

template <class ...ExtraArgs>
[[nodiscard]]
constexpr auto withArguments(ExtraArgs &&...args)
{
static_assert(std::tuple_size_v<TaskWithArgs> == 1,
"This function cannot be invoked if "
"arguments have already been passed.");

static_assert(sizeof...(ExtraArgs) >= 1,
"One or more arguments must be passed.");

// We have to re-create a builder, because the type has changed
return QTaskBuilder<Task, ExtraArgs...>(
startParameters,
std::get<0>(std::move(taskWithArgs)),
std::forward<ExtraArgs>(args)...
);
}

[[nodiscard]]
constexpr auto &onThreadPool(QThreadPool &newThreadPool)
{
startParameters.threadPool = &newThreadPool;
return *this;
}

[[nodiscard]]
constexpr auto &withPriority(int newPriority)
{
startParameters.priority = newPriority;
return *this;
}

protected: // Methods
constexpr explicit QTaskBuilder(Task &&task, Args &&...arguments)
: taskWithArgs{std::forward<Task>(task), std::forward<Args>(arguments)...}
{}

constexpr QTaskBuilder(
const TaskStartParameters &parameters, Task &&task, Args &&...arguments)
: taskWithArgs{std::forward<Task>(task), std::forward<Args>(arguments)...}
, startParameters{parameters}
{}

private: // Methods
// Required for creating a builder from "task" function
template <class T>
friend constexpr auto task(T &&t);

// Required for creating a new builder from "withArguments" function
template <class T, class ...A>
friend class QTaskBuilder;

private: // Data
using TaskWithArgs = DecayedTuple<Task, Args...>;

TaskWithArgs taskWithArgs;
TaskStartParameters startParameters;
};

} // namespace QtConcurrent

#endif // Q_QDOC

QT_END_NAMESPACE

#endif // !defined(QT_NO_CONCURRENT)

#endif //QTBASE_QTTASKBUILDER_H
10 changes: 10 additions & 0 deletions include/QtConcurrent/qtconcurrent_global.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#ifndef QTCONCURRENT_GLOBAL_H
#define QTCONCURRENT_GLOBAL_H

#include <QtCore/qglobal.h>
#include <QtConcurrent/qtconcurrentexports.h>

#endif // include guard
41 changes: 41 additions & 0 deletions include/QtConcurrent/qtconcurrentcompilertest.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#ifndef QTCONCURRENT_COMPILERTEST_H
#define QTCONCURRENT_COMPILERTEST_H

#include <QtConcurrent/qtconcurrent_global.h>

#ifndef QT_NO_CONCURRENT

QT_BEGIN_NAMESPACE

namespace QtPrivate {

template <class T, typename = void>
struct IsIterable : std::false_type {};
template <class T>
struct IsIterable<T, std::void_t<decltype(std::declval<T>().begin()),
decltype(std::declval<T>().end())>>
: std::true_type
{ };

template <class T>
inline constexpr bool IsIterableValue = IsIterable<T>::value;

template <class T, typename = void>
struct IsDereferenceable : std::false_type {};
template <class T>
struct IsDereferenceable<T, std::void_t<decltype(*std::declval<T>())>>
: std::true_type
{ };

template <class T>
inline constexpr bool IsDereferenceableValue = IsDereferenceable<T>::value;
}

QT_END_NAMESPACE

#endif // QT_NO_CONCURRENT

#endif
50 changes: 50 additions & 0 deletions include/QtConcurrent/qtconcurrentexports.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#ifndef QTCONCURRENTEXPORTS_H
#define QTCONCURRENTEXPORTS_H

#include <QtCore/qcompilerdetection.h>
#include <QtCore/qtconfigmacros.h> // Q_CONCURRENT_EXPORT
#include <QtCore/qtdeprecationmarkers.h> // QT_IF_DEPRECATED_SINCE

#if defined(QT_SHARED) || !defined(QT_STATIC)
# if defined(QT_BUILD_CONCURRENT_LIB)
# define Q_CONCURRENT_EXPORT Q_DECL_EXPORT
# else
# define Q_CONCURRENT_EXPORT Q_DECL_IMPORT
# endif
#else
# define Q_CONCURRENT_EXPORT
#endif

#if !defined(QT_BUILD_CONCURRENT_LIB) && !defined(QT_STATIC)
/* outside library -> inline decl + defi */
/* static builds treat everything as part of the library, so they never inline */
# define QT_CONCURRENT_INLINE_SINCE(major, minor) inline
# define QT_CONCURRENT_INLINE_IMPL_SINCE(major, minor) 1
#elif defined(QT_CONCURRENT_BUILD_REMOVED_API)
/* inside library, inside removed_api.cpp:
* keep deprecated API -> non-inline decl;
* remove deprecated API -> inline decl;
* definition is always available */
# define QT_CONCURRENT_INLINE_SINCE(major, minor) \
QT_IF_DEPRECATED_SINCE(major, minor, inline, /* not inline */)
# define QT_CONCURRENT_INLINE_IMPL_SINCE(major, minor) 1
#else
/* inside library, outside removed_api.cpp:
* keep deprecated API -> non-inline decl, no defi;
* remove deprecated API -> inline decl, defi */
# define QT_CONCURRENT_INLINE_SINCE(major, minor) \
QT_IF_DEPRECATED_SINCE(major, minor, inline, /* not inline */)
# define QT_CONCURRENT_INLINE_IMPL_SINCE(major, minor) \
QT_IF_DEPRECATED_SINCE(major, minor, 1, 0)
#endif

#ifdef QT_CONCURRENT_BUILD_REMOVED_API
# define QT_CONCURRENT_REMOVED_SINCE(major, minor) QT_DEPRECATED_SINCE(major, minor)
#else
# define QT_CONCURRENT_REMOVED_SINCE(major, minor) 0
#endif

#endif // QTCONCURRENTEXPORTS_H
Loading

0 comments on commit eeaadbf

Please sign in to comment.