Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Job handles, aka Here comes the future #754

Merged
merged 10 commits into from
May 13, 2024
Merged

Job handles, aka Here comes the future #754

merged 10 commits into from
May 13, 2024

Conversation

KitsuneRal
Copy link
Member

The centrepiece of this is in 91df7a7, specifically in jobhandle.cpp - the rest is introducing either JobHandle or QFuture in various contexts, as a proof of concept.

Closes #182.

@KitsuneRal KitsuneRal added the enhancement A feature or change request for the library label May 12, 2024
@KitsuneRal KitsuneRal marked this pull request as draft May 12, 2024 20:43
This makes for more idiomatic code, allows to invoke callbacks across
threads, spares the library from clumsy function signatures, and
prepares for connectSingleShot() deprecation.
@KitsuneRal KitsuneRal force-pushed the kitsune/proxy-future branch 3 times, most recently from d880c4c to 6dcd7a8 Compare May 13, 2024 08:02
Because this commit changes the returned type of Connection::callApi()
to JobHandle<JobT>, it will break the code that initialises an `auto*`
variable from Connection::callApi(). If the variable has a type of
`SpecificJob*`, implicit conversion of QPointer should maintain
compatibility; and if it's `auto` it can be later used as an ordinary
QPointer, too. But now you get the QFuture interface at `job.`, while
still having the job interface at `job->`.
[skip ci]
Both Apple Clang and MSVC fall through to the static_assert(false) that
doesn't depend (in itself) on template variables and trip on it even
though it is behind a constexpr if.

MSVC also doesn't handle mutable keyword on a lambda without
the parentheses and, separately, tumbles over with internal compiler
error, no less, on User::doSetAvatar() - even its (almost unchanged)
pre-future code upsets MSVC once callApi() starts returning JobHandle.
It should (ideally) come after all local dependencies are in.

[skip ci]
With Qt::SingleShotConnection and QtFuture::connect() around, there's
not much reason to have our means to the same end.
@KitsuneRal KitsuneRal force-pushed the kitsune/proxy-future branch 2 times, most recently from f9995d4 to 042442a Compare May 13, 2024 14:16
@KitsuneRal KitsuneRal marked this pull request as ready for review May 13, 2024 14:55
Skip is an empty structure, so we can optimise away pretty much
the entire BoundFn structure when it's initialised with {Skip, Skip}
(a case when then() is called with the single onSuccess argument).

Unfortunately, Clang either crashes with ICE or emits faulty code when
fn has no unique address (maybe because BoundFn::call() takes its
address to determine if it's a function pointer? I don't know); so that
no_unique_address is only added for compilers that can run with it.
@KitsuneRal KitsuneRal merged commit f52e009 into dev May 13, 2024
6 checks passed
@KitsuneRal KitsuneRal deleted the kitsune/proxy-future branch May 13, 2024 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A feature or change request for the library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Jobs as promises
2 participants